// Subpicture stuff private void SetupGraph(Guid clsidPresenter) { m_clsidPresenter = clsidPresenter; // Get a ICaptureGraphBuilder2 to help build the graph ICaptureGraphBuilder2 icgb2 = (ICaptureGraphBuilder2) new CaptureGraphBuilder2(); try { int hr; // Link the ICaptureGraphBuilder2 to the IFilterGraph2 hr = icgb2.SetFiltergraph(m_pGraph); DsError.ThrowExceptionForHR(hr); m_pEVR = (IBaseFilter) new EnhancedVideoRenderer(); hr = m_pGraph.AddFilter(m_pEVR, "EVR"); DsError.ThrowExceptionForHR(hr); InitializeEVR(m_pEVR, m_ImageHandlers.Length, out m_pDisplay); m_pPins = new IPin[m_ImageHandlers.Length]; for (int x = 0; x < m_ImageHandlers.Length; x++) { AddGSSF(m_ImageHandlers[x], icgb2, out m_pPins[x]); } // Get the seeking capabilities. hr = m_pSeek.GetCapabilities(out m_seekCaps); DsError.ThrowExceptionForHR(hr); } finally { Marshal.ReleaseComObject(icgb2); } // Update our state. m_state = PlaybackState.Stopped; }
/// <summary>Determines whether the specified IMediaSeeking can be used to retrieve duration and current position.</summary> /// <param name="seeking">The interface to check.</param> /// <returns>true if it can be used to retrieve duration and current position; false, otherwise.</returns> private static bool CanGetPositionAndDuration(IMediaSeeking seeking) { if (seeking == null) { return(false); } AMSeekingSeekingCapabilities caps; int hr = 0; hr = seeking.GetCapabilities(out caps); DsError.ThrowExceptionForHR(hr); if ((caps & AMSeekingSeekingCapabilities.CanGetDuration) != AMSeekingSeekingCapabilities.CanGetDuration) { return(false); } if ((caps & AMSeekingSeekingCapabilities.CanGetCurrentPos) != AMSeekingSeekingCapabilities.CanGetCurrentPos) { return(false); } return(true); }
private void TestBackingFileCount() { int hr; int iMin, iMax; int iMin2, iMax2; // Min=4, max=6 hr = m_isbc.GetBackingFileCount(out iMin, out iMax); DsError.ThrowExceptionForHR(hr); hr = m_isbc.SetBackingFileCount(7, 9); DsError.ThrowExceptionForHR(hr); hr = m_isbc.GetBackingFileCount(out iMin2, out iMax2); DsError.ThrowExceptionForHR(hr); Debug.Assert(iMin2 == 7, "set min"); Debug.Assert(iMax2 == 9, "set max"); hr = m_isbc.SetBackingFileCount(iMin, iMax); DsError.ThrowExceptionForHR(hr); }
protected void SaveSizeInfo(ISampleGrabber sampGrabber) { // Get the media type from the SampleGrabber AMMediaType media = new AMMediaType(); int hr = sampGrabber.GetConnectedMediaType(media); DsError.ThrowExceptionForHR(hr); if ((media.formatType != FormatType.VideoInfo) || (media.formatPtr == IntPtr.Zero)) { throw new NotSupportedException("Unknown Grabber Media Format"); } // Grab the size info VideoInfoHeader videoInfoHeader = (VideoInfoHeader)Marshal.PtrToStructure(media.formatPtr, typeof(VideoInfoHeader)); this.videoWidth = videoInfoHeader.BmiHeader.Width; this.videoHeight = videoInfoHeader.BmiHeader.Height; this.stride = this.videoWidth * (videoInfoHeader.BmiHeader.BitCount / 8); DsUtils.FreeAMMediaType(media); }
static void ConfigureAudioInput(DSGraph graph, Transcoder transcoder) { AMMediaType mt = new AMMediaType(); int hr; try { hr = graph.audioGrabber.GetConnectedMediaType(mt); DsError.ThrowExceptionForHR(hr); if ((mt.majorType != DirectShowLib.MediaType.Audio) || (mt.formatType != DirectShowLib.FormatType.WaveEx)) { throw new COMException("Unexpected format type"); } WaveFormatEx wfx = (WaveFormatEx)Marshal.PtrToStructure(mt.formatPtr, typeof(WaveFormatEx)); AudioStreamInfo audioInfo = new AudioStreamInfo(); audioInfo.BitsPerSample = wfx.wBitsPerSample; audioInfo.Channels = wfx.nChannels; audioInfo.SampleRate = wfx.nSamplesPerSec; audioInfo.StreamType = StreamType.LPCM; MediaSocket inputSocket = new MediaSocket(); MediaPin inputPin = new MediaPin(); inputPin.StreamInfo = audioInfo; inputSocket.Pins.Add(inputPin); inputSocket.StreamType = StreamType.LPCM; graph.audioGrabberCB.Init(transcoder, transcoder.Inputs.Count, graph.mediaControl); transcoder.Inputs.Add(inputSocket); } finally { DsUtils.FreeAMMediaType(mt); } }
public WaveFormatEx GetSampleGrabberFormat(ISampleGrabber sampleGrabber) { int hr; AMMediaType mediaInfo = new AMMediaType(); hr = sampleGrabber.GetConnectedMediaType(mediaInfo); DsError.ThrowExceptionForHR(hr); if ((mediaInfo.formatType != FormatType.WaveEx) || (mediaInfo.formatPtr == IntPtr.Zero)) { throw new NotSupportedException("Unknown Grabber Media Format"); } WaveFormatEx format = new WaveFormatEx(); format = (WaveFormatEx)Marshal.PtrToStructure(mediaInfo.formatPtr, typeof(WaveFormatEx)); Marshal.FreeCoTaskMem(mediaInfo.formatPtr); mediaInfo.formatPtr = IntPtr.Zero; return(format); }
public void HandleGraphEvent() { int hr = 0; EventCode evCode; IntPtr evParam1, evParam2; if (this.mediaEventEx == null) { return; } while (this.mediaEventEx.GetEvent(out evCode, out evParam1, out evParam2, 0) == 0) { // Free event parameters to prevent memory leaks associated with // event parameter data. While this application is not interested // in the received events, applications should always process them. hr = this.mediaEventEx.FreeEventParams(evCode, evParam1, evParam2); DsError.ThrowExceptionForHR(hr); // Insert event processing code here, if desired } }
void BuildGraph() { int hr; IBaseFilter ppFilter; DsDevice [] devs; IGraphBuilder graphBuilder = new FilterGraph() as IGraphBuilder; m_ROT = new DsROTEntry(graphBuilder); IFilterGraph2 ifg2 = graphBuilder as IFilterGraph2; devs = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice); DsDevice dev = devs[0]; hr = ifg2.AddSourceFilterForMoniker(dev.Mon, null, dev.Name, out ppFilter); DsError.ThrowExceptionForHR(hr); m_ivc = ppFilter as IAMVideoControl; m_IPinOut = DsFindPin.ByDirection(ppFilter, PinDirection.Output, 0); hr = ifg2.Render(m_IPinOut); DsError.ThrowExceptionForHR(hr); ICaptureGraphBuilder2 captureGraphBuilder = new CaptureGraphBuilder2() as ICaptureGraphBuilder2; hr = captureGraphBuilder.SetFiltergraph(graphBuilder); object o; hr = captureGraphBuilder.FindInterface(null, null, ppFilter, typeof(IAMAnalogVideoDecoder).GUID, out o); DsError.ThrowExceptionForHR(hr); m_avd = o as IAMAnalogVideoDecoder; m_imc = graphBuilder as IMediaControl; hr = m_imc.Run(); DsError.ThrowExceptionForHR(hr); }
void TestFileName() { int hr; string fn; AMMediaType pmt = new AMMediaType(); hr = m_ppsink.GetCurFile(out fn, pmt); DsError.ThrowExceptionForHR(hr); Debug.Assert(fn == FileName, "GetCurFile"); Debug.Assert(pmt.majorType == MediaType.Stream, "GetCurFile type"); Marshal.AddRef(pmt.unkPtr); hr = m_ppsink.SetFileName(@"c:\foo2.out", pmt); DsError.ThrowExceptionForHR(hr); hr = m_ppsink.GetCurFile(out fn, pmt); DsError.ThrowExceptionForHR(hr); Debug.Assert(fn == @"c:\foo2.out", "GetCurFile2"); }
void TestFrameRateList() { int hr; Size s = new Size(640, 480); int ls; IntPtr ip; hr = m_ivc.GetFrameRateList(m_IPinOut, 0, s, out ls, out ip); DsError.ThrowExceptionForHR(hr); for (int x = 0; x < ls; x++) { long l = Marshal.ReadInt64(ip, x * 8); Debug.WriteLine(l); } if (ip != IntPtr.Zero) { Marshal.FreeCoTaskMem(ip); ip = IntPtr.Zero; } }
/// <summary>Set up the filter graph for grabbing snapshots</summary> public void EnableGrabbing() { ICaptureGraphBuilder2 icgb2 = null; try { // Get a ICaptureGraphBuilder2 to help build the graph // Link the ICaptureGraphBuilder2 to the IFilterGraph2 icgb2 = new CaptureGraphBuilder2() as ICaptureGraphBuilder2; if (icgb2 == null) { throw new Exception("failed to create direct show CaptureGraphBuilder2"); } DsError.ThrowExceptionForHR(icgb2.SetFiltergraph(m_filter_graph)); // Get the SampleGrabber interface m_samp_grabber = (ISampleGrabber) new SampleGrabber(); { // Set the media type to Video/RBG24 AMMediaType media = new AMMediaType { majorType = MediaType.Video, subType = MediaSubType.RGB24, formatType = FormatType.VideoInfo }; try { DsError.ThrowExceptionForHR(m_samp_grabber.SetMediaType(media)); } finally { DsUtils.FreeAMMediaType(media); } } // Configure the sample grabber DsError.ThrowExceptionForHR(m_samp_grabber.SetBufferSamples(true)); // Add the sample graber to the filter graph IBaseFilter grab_filter = (IBaseFilter)m_samp_grabber; DsError.ThrowExceptionForHR(m_filter_graph.AddFilter(grab_filter, "DS.NET Grabber")); } finally { if (icgb2 != null) { Marshal.ReleaseComObject(icgb2); } } }
public void DoTests() { int hr = 0; try { BuildGraph(); hr = (graphBuilder as IMediaControl).Run(); DsError.ThrowExceptionForHR(hr); // Nothing is shown in the video window since we present nothing... System.Threading.Thread.Sleep(2000); hr = (graphBuilder as IMediaControl).Stop(); DsError.ThrowExceptionForHR(hr); // All methods need to be called at least once Debug.Assert(InitializeDeviceCount != 0, "IVMRSurfaceAllocator9.InitializeDevice"); Debug.Assert(GetSurfaceCount != 0, "IVMRSurfaceAllocator9.GetSurface"); Debug.Assert(TerminateDeviceCount != 0, "IVMRSurfaceAllocator9.TerminateDevice"); Debug.Assert(AdviseNotifyCount != 0, "IVMRSurfaceAllocator9.AdviseNotify"); Debug.Assert(StartPresentingCount != 0, "IVMRImagePresenter9.StartPresenting"); Debug.Assert(StopPresentingCount != 0, "IVMRImagePresenter9.StopPresenting"); Debug.Assert(PresentImageCount != 0, "IVMRImagePresenter9.PresentImage"); } finally { if (rot != null) { rot.Dispose(); } ReleaseDevice(); Marshal.ReleaseComObject(vmr9); Marshal.ReleaseComObject(graphBuilder); } }
void TestCrossbarInfo() { int hr; PhysicalConnectorType pctype; int opin, ipin; int iIsRelated; hr = m_ixbar.get_PinCounts(out opin, out ipin); DsError.ThrowExceptionForHR(hr); for (int x = 0; x < ipin; x++) { hr = m_ixbar.get_CrossbarPinInfo(true, x, out iIsRelated, out pctype); DsError.ThrowExceptionForHR(hr); } for (int y = 0; y < opin; y++) { hr = m_ixbar.get_CrossbarPinInfo(false, y, out iIsRelated, out pctype); DsError.ThrowExceptionForHR(hr); } }
private void InitializeGraph() { int hr = 0; TearDownGraph(); // Create the Filter Graph Manager. m_pGraph = (IGraphBuilder) new FilterGraph(); #if DEBUG m_rot = new DsROTEntry(m_pGraph); #endif // Query for graph interfaces. (These interfaces are exposed by the graph // manager regardless of which filters are in the graph.) m_pControl = (IMediaControl)m_pGraph; m_pEvent = (IMediaEventEx)m_pGraph; m_pSeek = (IMediaSeeking)m_pGraph; // Set up event notification. hr = m_pEvent.SetNotifyWindow(m_hwndEvent, m_EventMsg, IntPtr.Zero); DsError.ThrowExceptionForHR(hr); }
void SetFormat() { int hr = 0; pmt = new AMMediaType(); pmt.majorType = MediaType.Video; pmt.subType = MediaSubType.MJPG; pmt.formatType = FormatType.VideoInfo; pmt.fixedSizeSamples = false; //true for 640x480 pmt.formatSize = 88; pmt.sampleSize = 2764800; //2764800 614400 pmt.temporalCompression = false; ////////////////////////////////// format = new VideoInfoHeader(); format.SrcRect = new DsRect(); format.TargetRect = new DsRect(); format.BitRate = 5000000; format.AvgTimePerFrame = 666666; ////////////////////////////////// format.BmiHeader = new BitmapInfoHeader(); format.BmiHeader.Size = 40; format.BmiHeader.Width = 1280; format.BmiHeader.Height = 720; format.BmiHeader.Planes = 1; format.BmiHeader.BitCount = 24; format.BmiHeader.Compression = 1196444237; //1196444237 //844715353 format.BmiHeader.ImageSize = 2764800; //2764800 614400 pmt.formatPtr = Marshal.AllocCoTaskMem(Marshal.SizeOf(format)); Marshal.StructureToPtr(format, pmt.formatPtr, false); //Debug.WriteLine(getCatName(pUSB) + " at line 130"); streamConfig = (IAMStreamConfig)GetPin(pUSB, getCatName(pUSB)); hr = streamConfig.SetFormat(pmt); DsUtils.FreeAMMediaType(pmt); if (hr < 0) { CapTest.CustomMessage.ShowMessage("Can`t set format"); DsError.ThrowExceptionForHR(hr); } }
private void SetAllocatorPresenter() { int hr = 0; IVMRSurfaceAllocatorNotify9 vmrSurfAllocNotify = (IVMRSurfaceAllocatorNotify9)filter; try { allocator = new Allocator(this); hr = vmrSurfAllocNotify.AdviseSurfaceAllocator(userId, allocator); DsError.ThrowExceptionForHR(hr); hr = allocator.AdviseNotify(vmrSurfAllocNotify); DsError.ThrowExceptionForHR(hr); } catch { allocator = null; throw; } }
/// <summary> /// Adds VMR9 (renderer) filter to the filter graph. /// </summary> private void AddFilter_Renderer() { VMRenderer = (IBaseFilter) new VideoMixingRenderer9(); IVMRFilterConfig9 filterConfig = (IVMRFilterConfig9)VMRenderer; // Not really needed for vmr but don't forget calling it with VMR7 int hr = filterConfig.SetNumberOfStreams(1); DsError.ThrowExceptionForHR(hr); // Change vmr mode to Windowless hr = filterConfig.SetRenderingMode(VMR9Mode.Windowless); DsError.ThrowExceptionForHR(hr); // video renderer WindowlessCtrl = (IVMRWindowlessControl9)VMRenderer; // set clipping window hr = WindowlessCtrl.SetVideoClippingWindow(_DisplayPanel.Handle); DsError.ThrowExceptionForHR(hr); // Set Aspect-Ratio hr = WindowlessCtrl.SetAspectRatioMode(VMR9AspectRatioMode.LetterBox); DsError.ThrowExceptionForHR(hr); // Add delegates for Windowless operations _DisplayPanel.Paint += new PaintEventHandler(HostingControl_Paint); // for WM_PAINT _DisplayPanel.Resize += new EventHandler(HostingControl_ResizeMove); // for WM_SIZE _DisplayPanel.Move += new EventHandler(HostingControl_ResizeMove); // for WM_MOVE SystemEvents.DisplaySettingsChanged += new EventHandler(SystemEvents_DisplaySettingsChanged); // for WM_DISPLAYCHANGE _bHandlersAdded = true; // Call the resize handler to configure the output size HostingControl_ResizeMove(null, null); hr = FilterGraph.AddFilter(VMRenderer, "Video Mixing Renderer 9"); DsError.ThrowExceptionForHR(hr); }
public void Show(IntPtr hWnd) { var cauuid = new DsCAUUID(); try { int hr = m_specifyPropertyPages.GetPages(out cauuid); if (hr != 0) { Marshal.ThrowExceptionForHR(hr); } object objRef = m_specifyPropertyPages; hr = OleCreatePropertyFrame(hWnd, 30, 30, null, 1, ref objRef, cauuid.cElems, cauuid.pElems, 0, 0, IntPtr.Zero); DsError.ThrowExceptionForHR(hr); } catch (Exception) { MessageBox.Show(NO_PROPERTY_PAGE_FOUND); } finally { if (cauuid.pElems != IntPtr.Zero) { Marshal.FreeCoTaskMem(cauuid.pElems); } } }
/// <summary> /// Starts the stream (runs the graph) /// </summary> public virtual void Run() { lock (instanceMutex) { int hr; if (_mediaControl != null) { if (_resetRequiredNextRun) { LoadNetSrcURL(); _mediaControl.Stop(); } hr = _mediaControl.Run(); DsError.ThrowExceptionForHR(hr); if (_telemetryTimer != null) { _telemetryTimer.Change(5000, -1); //invoke timer in 5 sec } } } }
private int ModifyRate(double dRateAdjust) { int hr = 0; double dRate; // If the IMediaSeeking interface exists, use it to set rate if ((this.mediaSeeking != null) && (dRateAdjust != 0.0)) { hr = this.mediaSeeking.GetRate(out dRate); DsError.ThrowExceptionForHR(hr); // Add current rate to adjustment value double dNewRate = dRate + dRateAdjust; hr = this.mediaSeeking.SetRate(dNewRate); DsError.ThrowExceptionForHR(hr); // Save global rate this.currentPlaybackRate = dNewRate; } return(hr); }
public virtual void Start() { if (this.thread == null) { this.resetEvent = new ManualResetEvent(false); // create and start new thread this.thread = new Thread(this.CaptureThread) { Name = "DirectShow " + this.GetType().Name + " Thread" }; this.thread.Start(); } if (this.State == GraphState.Paused) { int hr = this.MediaCtrl.Run(); DsError.ThrowExceptionForHR(hr); this.State = GraphState.Running; } }
public static void DisconnectPins(IBaseFilter filter) { int hr = 0; if (filter == null) { throw new ArgumentNullException("filter"); } IEnumPins enumPins; IPin[] pins = new IPin[1]; hr = filter.EnumPins(out enumPins); DsError.ThrowExceptionForHR(hr); IntPtr fetched = Marshal.AllocCoTaskMem(4); try { while (enumPins.Next(pins.Length, pins, fetched) == 0) { try { hr = pins[0].Disconnect(); DsError.ThrowExceptionForHR(hr); } finally { Marshal.ReleaseComObject(pins[0]); } } } finally { Marshal.FreeCoTaskMem(fetched); Marshal.ReleaseComObject(enumPins); } }
public void TestReset() { int hr; IntPtr ip = Marshal.AllocCoTaskMem(4); AMMediaType[] ppMediaTypes = new AMMediaType[1]; IEnumMediaTypes enumMediaTypes = GetEnumMediaTypes(); hr = enumMediaTypes.Next(ppMediaTypes.Length, ppMediaTypes, ip); DsError.ThrowExceptionForHR(hr); Debug.Assert(Marshal.ReadInt32(ip) == 1, "Next"); hr = enumMediaTypes.Reset(); DsError.ThrowExceptionForHR(hr); hr = enumMediaTypes.Next(1, ppMediaTypes, IntPtr.Zero); DsError.ThrowExceptionForHR(hr); Marshal.FreeCoTaskMem(ip); }
void TestMenuLang() { int hr; int pulActualLanguages; hr = m_idi2.GetMenuLanguages(null, 0, out pulActualLanguages); DsError.ThrowExceptionForHR(hr); int [] pLanguages = new int[pulActualLanguages + 1]; hr = m_idi2.GetMenuLanguages(pLanguages, pLanguages.Length, out pulActualLanguages); DsError.ThrowExceptionForHR(hr); Debug.Assert(pLanguages[0] == 1033, "GetMenuLanguages"); int pMLLanguage; hr = m_idi2.GetDefaultMenuLanguage(out pMLLanguage); DsError.ThrowExceptionForHR(hr); Debug.Assert(pMLLanguage == 1033, "GetDefaultMenuLanguage"); }
private void ConfigureSampleGrabber(ISampleGrabber sampGrabber) { AMMediaType media; int hr; media = new AMMediaType(); media.majorType = MediaType.Audio; /*media.subType = MediaSubType.WAVE; * media.formatType = FormatType.WaveEx;*/ hr = sampGrabber.SetMediaType(media); DsError.ThrowExceptionForHR(hr); DsUtils.FreeAMMediaType(media); media = null; // Configure the samplegrabber hr = sampGrabber.SetCallback(this, 1); // buffer callback (0 = Sample callback) DsError.ThrowExceptionForHR(hr); }
void TestTitle() { int hr; DvdParentalLevel pulTParentalLevels; int pulNumOfChapters; hr = m_idi2.GetNumberOfChapters(1, out pulNumOfChapters); DsError.ThrowExceptionForHR(hr); Debug.Assert(pulNumOfChapters == 2, "TestTitle"); hr = m_idi2.GetTitleParentalLevels(1, out pulTParentalLevels); DsError.ThrowExceptionForHR(hr); Debug.Assert(pulTParentalLevels == (DvdParentalLevel.Level1 | DvdParentalLevel.Level2 | DvdParentalLevel.Level3 | DvdParentalLevel.Level4 | DvdParentalLevel.Level5 | DvdParentalLevel.Level6 | DvdParentalLevel.Level7 | DvdParentalLevel.Level8), "TestTitle2"); DvdDecoderCaps pCaps = new DvdDecoderCaps(); pCaps.dwSize = Marshal.SizeOf(pCaps); hr = m_idi2.GetDecoderCaps(ref pCaps); DsError.ThrowExceptionForHR(hr); Debug.Assert(pCaps.dwAudioCaps == (DvdAudioCaps.AC3 | DvdAudioCaps.MPEG2 | DvdAudioCaps.DTS | DvdAudioCaps.SDDS), "TestTitle3"); DvdMenuAttributes pMenu = new DvdMenuAttributes(); DvdTitleAttributes pTitle = new DvdTitleAttributes(); hr = m_idi2.GetTitleAttributes(1, out pMenu, pTitle); DsError.ThrowExceptionForHR(hr); Debug.Assert(pMenu.VideoAttributes.sourceResolutionX == 720, "TestDiskInfo4"); Debug.Assert(pTitle.ulNumberOfAudioStreams == 1, "TestTitle5"); }
private void ConfigureSampleGrabber(ISampleGrabber sampGrabber) { AMMediaType media; int hr; // Set the media type to Video/RBG24 media = new AMMediaType(); media.majorType = MediaType.Video; media.subType = MediaSubType.RGB24; media.formatType = FormatType.VideoInfo; sampGrabber.SetBufferSamples(false); sampGrabber.SetOneShot(false); hr = sampGrabber.SetMediaType(media); DsError.ThrowExceptionForHR(hr); DsUtils.FreeAMMediaType(media); media = null; // Configure the samplegrabber hr = sampGrabber.SetCallback(this, 1); DsError.ThrowExceptionForHR(hr); }
void TestMixLevel() { int hr; double MixLevelValue1, MixLevelValue2; const double pFixed = .77777; try { // Read the current value hr = m_iaim.get_MixLevel(out MixLevelValue1); DsError.ThrowExceptionForHR(hr); // Write a different value hr = m_iaim.put_MixLevel(pFixed); DsError.ThrowExceptionForHR(hr); // Re-read the value hr = m_iaim.get_MixLevel(out MixLevelValue2); DsError.ThrowExceptionForHR(hr); // See if the value changed. Allow for imperfections from using double. Debug.Assert((int)(MixLevelValue2 * 10000) == (int)(pFixed * 10000), "Get/Set MixLevel"); // Put the original back hr = m_iaim.put_MixLevel(MixLevelValue1); DsError.ThrowExceptionForHR(hr); } catch (COMException ex) { if (ex.ErrorCode == -2147467263) { System.Windows.Forms.MessageBox.Show("This audio card doesn't support MixLevel"); } else { throw; } } }
// Configure the video window private void ConfigureVideoWindow(IVideoWindow videoWindow, Control hWin) { int hr; // Set the output window hr = videoWindow.put_Owner(hWin.Handle); DsError.ThrowExceptionForHR(hr); // Set the window style hr = videoWindow.put_WindowStyle((WindowStyle.Child | WindowStyle.ClipChildren | WindowStyle.ClipSiblings)); DsError.ThrowExceptionForHR(hr); // Make the window visible hr = videoWindow.put_Visible(OABool.True); DsError.ThrowExceptionForHR(hr); // Position the playing location Rectangle rc = hWin.ClientRectangle; hr = videoWindow.SetWindowPosition(0, 0, rc.Right, rc.Bottom); DsError.ThrowExceptionForHR(hr); }
protected override Channel GetChannel() { ITuneRequest request; int hr = tuner.get_TuneRequest(out request); DsError.ThrowExceptionForHR(hr); IATSCChannelTuneRequest atscRequest = (IATSCChannelTuneRequest)request; ILocator locator; atscRequest.get_Locator(out locator); IATSCLocator atscLocator = (IATSCLocator)locator; int freq, channel, major, minor; hr = atscLocator.get_CarrierFrequency(out freq); hr = atscLocator.get_PhysicalChannel(out channel); hr = atscRequest.get_Channel(out major); hr = atscRequest.get_MinorChannel(out minor); return(new Channel(freq, channel, major, minor)); }