`
isiqi
  • 浏览: 16366489 次
  • 性别: Icon_minigender_1
  • 来自: 济南
社区版块
存档分类
最新评论

windows ce directshow播放视频

阅读更多

The following sample program renders a file named Test.avi inside an application window. For brevity, it omits the following functionality:

  • It does not resize the video window when the parent window is resized. To accomplish this, call IVideoWindow::SetWindowPosition again in response to a WM_SIZE message on the parent window.
  • It performs no error checking.
  • It stretches the video window without regard to the aspect ratio of the source. To determine the aspect ratio, use the IBasicVideo interface.
  • It does not handle end-of-stream events. For information on how to do this, see Responding to Events.
NoteTo make the following code example easier to read, error checking is not included. Do not use this code example in a release configuration unless it you have modified it to include secure error handling.
#include <windows.h>
#include <streams.h>

#define CLASSNAME "VideoWindow"

IGraphBuilder   *pGraph = NULL;
IMediaControl   *pMediaControl = NULL;
IVideoWindow    *pVidWin = NULL;
HWND            g_hwnd;

void PlayFile(void)
{
    // Create the filter graph manager.
    CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC, 
        IID_IGraphBuilder, (void **)&pGraph);
    pGraph->QueryInterface(IID_IMediaControl, (void **)&pMediaControl);
    pGraph->QueryInterface(IID_IVideoWindow, (void **)&pVidWin);

    // Build the graph. 
    pGraph->RenderFile(L"Test.avi", NULL);

    //Set the video window. 

//Attach the video playback window to the desired parent window.

//call the IVideoWindow::put_Owner method and pass it a handle to the owner window.

pVidWin->put_Owner((OAHWND)g_hwnd);

pVidWin->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS); RECT grc; GetClientRect(g_hwnd, &grc); pVidWin->SetWindowPosition(0, 0, grc.right, grc.bottom); // Run the graph. pMediaControl->Run(); } void CleanUp(void) {

//Before the application exits, it is important that

//you set the visibility of the video window to false.

// Otherwise, a video image remains on the screen

//and the user cannot get rid of it. Then, reset the owner to NULL;

//otherwise, messages are sent to the wrong window, likely causing errors.

pVidWin->put_Visible(OAFALSE); pVidWin->put_Owner(NULL); pMediaControl->Release(); pVidWin->Release(); pGraph->Release(); } // Message handler. long FAR PASCAL WindowProc( HWND hwnd, UINT msg, UINT wParam, LONG lParam) { switch (msg) { case WM_DESTROY: CleanUp(); PostQuitMessage(0); break; default: return (DefWindowProc(hwnd, msg, wParam, lParam)); } return(NULL); } // Main. int PASCAL WinMain( HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR pCmdLine, int nCmdShow ) { MSG msg; WNDCLASS wc; CoInitialize(NULL); ZeroMemory(&wc, sizeof wc); wc.lpfnWndProc = WindowProc; wc.hInstance = hInst; wc.hIcon = LoadIcon( NULL, IDI_APPLICATION ); wc.hCursor = LoadCursor( NULL, IDC_ARROW ); wc.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH ); wc.lpszMenuName = NULL; wc.lpszClassName = CLASSNAME; RegisterClass( &wc ); g_hwnd = CreateWindow( CLASSNAME, "DirectShow Sample", (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX), CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInst, NULL); ShowWindow( g_hwnd, nCmdShow ); UpdateWindow( g_hwnd ); PlayFile(); while( GetMessage( &msg, NULL, 0, 0 ) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); } CoUninitialize(); return msg.wParam; }

<!-- <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"> <rdf:Description rdf:about="http://ustcers.com/blogs/devzhao/articles/13033.aspx" dc:identifier="http://ustcers.com/blogs/devzhao/articles/13033.aspx" dc:title="windows ce directshow播放视频" trackback:ping="http://ustcers.com/blogs/trackback.aspx?PostID=13033" /> </rdf:RDF> -->
分享到:
评论

相关推荐

    DirectShow视频捕捉应用研究

    本文将对从捕捉设备和从播放文件中进行视频捕捉涉及的有关驱动(Driver)与应用的模型和接口进行研究和分析,比较其Windows与Windows CE中的不同,从而提出在Windows CE下实现视频捕捉数据流的方法。

    Windows CE视频电话的音视频同步

    ### Windows CE视频电话的音视频同步 #### 概述 随着嵌入式视频电话应用的日益普及,确保高质量的通话体验成为了技术开发的关键。在基于SIP协议的嵌入式视频电话系统中,音视频同步不仅是用户体验的重要保障,也是...

    windows mobile下的directshow Baseclasses

    DirectShow是微软开发的一个强大的多媒体处理框架,广泛应用于视频捕获、播放、编辑等领域。在Windows Mobile操作系统上,DirectShow同样被用来实现多媒体内容的处理和播放。"Baseclasses"是DirectShow的一部分,它...

    Window下通过DirectShow控制USB摄像头抓拍照片

    DirectShow是微软提供的一种多媒体处理框架,它为开发者提供了强大的音视频捕获、播放和编辑功能。本教程将深入讲解如何使用DirectShow来实现USB摄像头的图像抓取。 首先,了解DirectShow的基本概念。DirectShow是...

    directshow

    DirectShow是微软开发的一个强大的多媒体框架,主要用于处理音频和视频数据。它在Windows CE系统上也能运行,使得在嵌入式设备上开发多媒体应用成为可能。在这个特定的场景下,我们讨论的是如何在WinCE(Windows ...

    WINCE 基于DIRECTSHOW 的音频视频播放器

    在播放器中,这可能用于从摄像头源直接获取并播放视频流。 综上所述,基于DirectShow的WINCE音频视频播放器开发涵盖了从媒体处理、解码、过滤图构建到用户交互的多个层面,需要对DirectShow框架有深入理解,并具备...

    directshow资料

    6. **Windows CE支持(WinCE DShow)**:在Windows CE平台上,DirectShow也有相应的实现,尽管功能可能有所精简,但核心概念和API保持一致,允许在嵌入式设备上实现多媒体功能。 7. **开发工具**:开发DirectShow...

    WINCE下的视频播放软件

    在WINCE上播放视频,首先要了解常见的视频编码格式。常见的有MPEG-4、H.264、VP9、AVI、WMV等。其中,H.264和MPEG-4因其高效率的压缩算法,在保持画质的同时降低了文件大小,是移动设备上常用的编码格式。而VP9作为...

    HTML播放视频代码

    在这里,我们使用了RealPlayer或Windows Media Player的ActiveX控件来播放视频。`classid`属性指定了播放器的类型,而`&lt;param&gt;`标签则定义了播放器的各种设置,如显示控制、自动播放等。嵌套的`&lt;embed&gt;`标签是为了...

    采用directshow架构实现的嵌入式远程音视频传输系统

    DirectShow是由Microsoft开发的一套多媒体框架,主要用于Windows平台上音视频流的捕捉、压缩、播放等一系列操作。DirectShow的核心机制是Filter Graph模型,它允许开发者以组件化的方式构建复杂的多媒体应用,每个...

    Wince DirectShow Camera

    在Windows CE(Wince)平台上,利用DirectShow技术来实现实时摄像头预览、拍照以及录制视频是一项常见的任务。DirectShow是微软提供的一种强大的多媒体框架,它为开发人员提供了丰富的功能,可以处理音频和视频流。...

    avi_file_source.rar_AVI Source_avi filter_directshow wince_wince

    在IT行业中,DirectShow是微软开发的一个用于多媒体流处理的框架,它允许开发者创建和播放各种音频和视频格式。在Windows CE(一种嵌入式操作系统)环境下,由于资源限制和特定的需求,DirectShow的实现与桌面系统...

    divxdec_ax.rar_Directshow Filter_divx_divx wince_divx directsho

    综上所述,这个压缩包内容涵盖了DivX MPEG-4视频解码的核心技术,包括DirectShow Filter的实现,以及在Windows CE平台上的应用。对于开发者来说,这些源代码和相关信息提供了深入学习解码机制、定制解码器或优化...

    win32的directshow解码演示(vs2008平台)

    我们将探讨如何在Visual Studio 2008环境下使用C++语言实现DirectShow的解码功能,并且讨论如何将这个解决方案移植到Windows CE(Wince)系统,以适应移动设备的视频解码需求。 1. **DirectShow基础知识** - ...

    Windows Mobile 6 EricMeidaPlayer

    通过C++编程和DirectShow框架,开发者可以构建出强大的媒体播放解决方案,同时结合Windows CE的UI设计,提供优秀的用户体验。这个项目不仅涉及了底层的媒体处理,还包括了上层的用户交互设计,是学习和研究嵌入式...

    uvcdirectshowdemo_ce6_01_02_uvcamcab_

    在Windows CE 6中,由于资源限制,DirectShow的实现可能比桌面版Windows简洁一些,但依然能提供基本的视频捕获功能。开发者可以通过调用DirectShow API,创建和配置滤镜图来实现摄像头应用。例如,可以使用`...

    WinCE Dump Filter

    在Windows CE(WinCE)操作系统上,实现视频播放功能通常会依赖Directshow框架。Directshow是Microsoft开发的一个强大的多媒体处理平台,用于视频和音频的播放、录制以及处理。在WinCE 6.0系统中,为了对视频流进行...

    OpenCV.zip_Windows_CE_Visual_C++_

    `setting_dshow.txt`可能涉及的是DirectShow相关设置,DirectShow是Windows平台用于多媒体处理的框架,常用于视频捕获和播放。文件内容可能涵盖: 1. **DirectShow集成**:OpenCV在Windows CE上可能依赖DirectShow...

    WinCE版DSHOW

    6. **应用实例**:在Windows CE设备上,DirectShow可以用于开发实时视频监控、流媒体播放、视频会议等应用。 7. **开发工具**:Visual Studio可以用于开发DirectShow.NET CF应用程序,配合DirectShow SDK和.NET ...

Global site tag (gtag.js) - Google Analytics