Skip to content

Commit

Permalink
Fork : Add checked return code for IPTV when adding filter.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastiii committed Jul 5, 2014
1 parent ea00a19 commit 37cb034
Showing 1 changed file with 44 additions and 26 deletions.
Expand Up @@ -56,36 +56,54 @@ public TvCardDVBIPBuiltIn(DsDevice device, int sequence)
/// <param name="url"></param>
protected override void AddStreamSourceFilter(string url)
{
Log.Log.WriteFile("dvbip:Add MediaPortal IPTV Source Filter");
_filterStreamSource = FilterGraphTools.FindFilterByClsid(_graphBuilder, typeof(MPIPTVSource).GUID);

if (_filterStreamSource == null)
try
{
_filterStreamSource = FilterGraphTools.AddFilterFromClsid(_graphBuilder, typeof (MPIPTVSource).GUID,
"MediaPortal IPTV Source Filter");
}
Log.Log.WriteFile("dvbip:Add MediaPortal IPTV Source Filter");
_filterStreamSource = FilterGraphTools.FindFilterByClsid(_graphBuilder, typeof (MPIPTVSource).GUID);

if (_filterStreamSource == null)
{
_filterStreamSource = FilterGraphTools.AddFilterFromClsid(_graphBuilder, typeof (MPIPTVSource).GUID,
"MediaPortal IPTV Source Filter");
}

AMMediaType mpeg2ProgramStream = new AMMediaType();
mpeg2ProgramStream.majorType = MediaType.Stream;
mpeg2ProgramStream.subType = MediaSubType.Mpeg2Transport;
mpeg2ProgramStream.unkPtr = IntPtr.Zero;
mpeg2ProgramStream.sampleSize = 0;
mpeg2ProgramStream.temporalCompression = false;
mpeg2ProgramStream.fixedSizeSamples = true;
mpeg2ProgramStream.formatType = FormatType.None;
mpeg2ProgramStream.formatSize = 0;
mpeg2ProgramStream.formatPtr = IntPtr.Zero;
DateTime dtNow = DateTime.Now;
((IFileSourceFilter)_filterStreamSource).Load(url, mpeg2ProgramStream);
TimeSpan ts = DateTime.Now - dtNow;
//connect the [stream source] -> [inf tee]
Log.Log.WriteFile("dvb: Render [source]->[inftee]");
int hr = _capBuilder.RenderStream(null, null, _filterStreamSource, null, _infTeeMain);
if (hr != 0 || ts.TotalSeconds > 3)
if (_filterStreamSource != null)
{
AMMediaType mpeg2ProgramStream = new AMMediaType();
mpeg2ProgramStream.majorType = MediaType.Stream;
mpeg2ProgramStream.subType = MediaSubType.Mpeg2Transport;
mpeg2ProgramStream.unkPtr = IntPtr.Zero;
mpeg2ProgramStream.sampleSize = 0;
mpeg2ProgramStream.temporalCompression = false;
mpeg2ProgramStream.fixedSizeSamples = true;
mpeg2ProgramStream.formatType = FormatType.None;
mpeg2ProgramStream.formatSize = 0;
mpeg2ProgramStream.formatPtr = IntPtr.Zero;
DateTime dtNow = DateTime.Now;
int filterStreamSource = ((IFileSourceFilter) _filterStreamSource).Load(url, mpeg2ProgramStream);

This comment has been minimized.

Copy link
@georgius

georgius Jul 5, 2014

Better:

int hr = ((IFileSourceFilter) _filterStreamSource).Load(url, mpeg2ProgramStream);

if (filterStreamSource != 0)

This comment has been minimized.

Copy link
@georgius

georgius Jul 5, 2014

if (hr != 0)

{
Log.Log.Error("dvb:Add source returns:0x{0:X}", filterStreamSource);

This comment has been minimized.

Copy link
@georgius

georgius Jul 5, 2014

Log.Log.Error("dvb:Add source returns:0x{0:X}", hr);

RemoveStreamSourceFilter();
throw new TvException("Unable to add source filter");
}
TimeSpan ts = DateTime.Now - dtNow;
//connect the [stream source] -> [inf tee]
Log.Log.WriteFile("dvb: Render [source]->[inftee]");
int hr = _capBuilder.RenderStream(null, null, _filterStreamSource, null, _infTeeMain);

This comment has been minimized.

Copy link
@georgius

georgius Jul 5, 2014

Better (remove int, because defined earlier):

hr = _capBuilder.RenderStream(null, null, _filterStreamSource, null, _infTeeMain);

This comment has been minimized.

Copy link
@Sebastiii

Sebastiii Jul 6, 2014

Author Owner

Thanks :) i will push the change :)

if (hr != 0 || ts.TotalSeconds > 3)
{
Log.Log.Error("dvb:Add source returns:0x{0:X}", hr);
RemoveStreamSourceFilter();
throw new TvException("Unable to add source filter");
}
}
}
catch (Exception)
{
Log.Log.Error("dvb:Add source returns:0x{0:X}", hr);
Log.Log.Error("dvb:Unable to add AddStreamSourceFilter");
RemoveStreamSourceFilter();
throw new TvException("Unable to add source filter");
throw new TvException("Unable to add source filter");
}
}

Expand Down

0 comments on commit 37cb034

Please sign in to comment.