forked from MediaPortal/MediaPortal-1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fork : Add checked return code for IPTV when adding filter.
- Loading branch information
Showing
1 changed file
with
44 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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.
Sorry, something went wrong. |
||
if (filterStreamSource != 0) | ||
This comment has been minimized.
Sorry, something went wrong. |
||
{ | ||
Log.Log.Error("dvb:Add source returns:0x{0:X}", filterStreamSource); | ||
This comment has been minimized.
Sorry, something went wrong. |
||
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.
Sorry, something went wrong.
georgius
|
||
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"); | ||
} | ||
} | ||
|
||
|
Better:
int hr = ((IFileSourceFilter) _filterStreamSource).Load(url, mpeg2ProgramStream);