Media Player Plugins in Windows Mobile Multimedia Development Summary

Source: Internet
Author: User
Document directory
  • Windows Media Player Skins
  • Windows Media Player Plug-ins

Media Player Plugins in Windows Mobile Multimedia Development Summary

 

With the popularization of 3G networks, technical demands such as multimedia and streaming media will increase, such as video calls. However, there are not many senior talents in this field in China, which gives us a direction for these technologies. :)

There are two options for Media Player Development in Windows Mobile: Extended Windows Media Player (WMP) and self-developed player (DirectShow, or use an open-source library, such as decoding the libmad library of MP3 ). Developing a player is a big nut to crack. Unfortunately, there is no such project requirement.

This article only summarizes the WMP extensions in Windows Mobile 6.0/6.1 (wm6.0/6.1). wm6.0/6.1 uses wmp10. For details, see.

WMP for wm6.5 not listed by Microsoft is also version 10. For details, see. You can see that the menu style has been changed, and the others have not changed. I don't know if there are any changes in WMP extension development.

Download the WMP 10 SDK from the Internet (only the SDK for the desktop system, no mobile version, and the documentation is only in English ):
Http://msdn.microsoft.com/en-us/windowsmedia/bb190309.aspx

First, we will summarize the extended development of WMP In the desktop operating system. Windows Media Player mobile is a subset of media player.

Windows Media Player Skins

Microsoft fully supports skin on mobile. If you want to design a Windows Media Player with beautiful personality on mobile, You need to design pictures of each part (such as when buttons are available or unavailable) and skin definition file. Display the Windows Media Player on HTC's windows mobile device. For more information, see the SDK. the SDK has a special article titled Windows Media Player for Windows Mobile skins.

Windows Media Player Plug-ins

Only User Interface plug-ins (marked in red below) are supported on mobile ).

★DSP plug-ins

-> Provides an architecture that enables the user to install and activate plug-in programs that add digital signal processing (DSP) functionality. DSP plug-ins are Microsoft DirectX Media objects (DMOs) that connect to the player by using COM interfaces. A typical DSP plug-in might be an Audio Equalizer or a video tint control. (used for data signal processing, such as a balance, for example)

How to let WMP know your existence? The method is to call the iwmpmediapluginregistrar: wmpregisterplayerplugin method to register with WMP.

How to communicate with WMP? WMP provides audio and video data to the plug-in by providing an allocated input buffer, and the plug-in returns data to the output buffer (which is also allocated by WMP.
WMP manages data transmission between itself and the plug-in by calling the method implemented by the plug-in. The process is as follows:

1. Windows Media Player CILS imediaobject: processinput, passing a pointer to an imediabuffer object to the DSP plug-in.

2. the DSP plug-in keeps a reference count on the input buffer object. The DSP plug-in returns an appropriate success or failure hresult.

3. Windows Media Player CILS imediaobject: processoutput, passing a pointer to an array of dmo_output_data_buffer structures (which contain output buffers) to the DSP plug-in.

4. the DSP plug-in processes the data in the input buffer and then copies the data to the appropriate output buffer. the DSP plug-in releases the reference count on the input buffer object when all the data in the buffer has been processed. the DSP plug-in then returns an appropriate success or failure hresult.

5. Windows Media Player renders the content in the output buffer.
This process repeats continuously while the plug-in is enabled and Windows Media Player has content to render.

Doprocessoutput (processing audio data of interest in this function) is called each time Windows Media Player successfully CILS imediaobject: processoutput. it is the function that performs the digital signal processing tasks that produce the audible result that the DSP plug-in is intended to produce.
For example, if the current plug-in is not activated, the doprocessoutput method should be implemented as follows:
// Test whether the plug-in is disabled by the user.
If (! M_benabled)
{
// Just copy the data without changing it.
Memcpy (pboutputdata, m_pbinputdata, * cbbytesprocessed );

Return s_ OK;
}

Related interfaces and descriptions
Imediaobject manages data exchange with Windows Media Player and performs digital signal processing tasks. Detailed documentation is encoded with the DirectX SDK.
Iwmpmediapluginregistrar manages plug-in registration.
Iwmpplugin manages the connection to Windows Media Player.
Iwmppluginenable stores whether the plug-in is currently enabled by Windows Media Player.
Iwmpservices retrieves information from the player about the current stream time and stream state.

Enumeration types and descriptions
Wmpplugin_caps used with iwmpplugin: getcaps to indicate whether the plug-in can convert between formats.
Wmpservices_streamstate indicates the whether the stream is currently stopped, paused, or playing.
Bytes ----------------------------------------------------------------------------------------------

★Custom visualizations

-> Windows Media Player provides your code with snapshots of audio frequency and waveform data at timed intervals measured in fractions of a second. the graphical output from your visualization is a Microsoft Windows device context. this is a standard Windows drawing surface that you can draw upon every time an audio snapshot is provided. (used to output visual effects based on Audio Information, for example)

Related interfaces and descriptions
Iwmpeffects interface an interface to custom visualizations.
Iwmp1_ts2 interface an interface that extends iwmpeffects, allowing greater control over visualization behavior.

Related struct and enumeration types
Playerstate provides some basic states of Windows Media Player.
Timedlevel holds data returned from the spectrum filter.
Bytes ----------------------------------------------------------------------------------------------

★User Interface plug-ins

-> Provides a variety of control panels that allow the user to modify various aspects of the player such as the video and graphic equalizer settings. skins are one way to provide additional functionality, but they require the developer to recreate the entire user interface (UI ). as an alternative, Windows Media Player allows the creation of custom UI plug-ins that display in the full mode of the PL Ayer. This functionality is provided through a programming interface that follows standard Microsoft Component Object Model (COM) guidelines. (it can implement some UI customization, making up for the deficiency that all UIS must be customized by skin. The plug-in must be developed in the form of a COM server. Therefore, you must not only implement the iwmppluginui interface, but also implement the interface required by the COM server, such as dllgetclassobject, dllcanunloadnow, and dllregisterserver, it is more convenient to use ATL .)

  • Display area plug-ins
  • Settings area plug-ins
  • Metadata area plug-ins
  • Separate window plug-ins
  • Background plug-ins (Windows Mobile only supports this type. It is not clear whether more versions 6.5 and later support this type)

    Related interfaces and descriptions
    Wmpnotifypluginaddremove an independent function used to your y Windows Media Player that a plug-in has been installed or uninstalled.
    Methods In iwmppluginui:
    Create called by Windows Media Player to instantiate the plug-in user interface.
    Destroy called by Windows Media Player to shut down the plug-in user interface.
    Displaypropertypage called by Windows Media Player to request that the plug-in display its property page.
    Getproperty called by Windows Media Player to retrieve name/value property pairs from the plug-in.
    Setcore called by Windows Media Player to provide plug-in access to the core Windows Media Player APIs. (This is a key method. You want to obtain a WMP interface pointer through this method, and then you can use this pointer to further obtain interface pointers such as iwmpcontrols and iwmpsettings, these interface pointers provide methods to control WMP. )
    Setproperty called by Windows Media Player to set name/value property pairs for the plug-in.
    Translateaccelerator called as part of the Windows Media Player message loop to allow the plug-in to intercept and respond to Keyboard Events.

    Registry Key location (WMP traverses this location every time it starts, and WMP continues to find your DLL file for loading)
    HKEY_LOCAL_MACHINE/software/Microsoft/mediaplayer/uiplugins/{classid}
    Bytes ----------------------------------------------------------------------------------------------

    ★Rendering plug-ins

    -> Microsoft Windows Media Player provides an architecture that enables you to develop plug-ins that decode (if necessary) and render custom data contained in a Windows Media Format stream.

    Related interfaces and descriptions
    Iwmpmediapluginregistrar manages plug-in registration.
    Iwmpnoderealestate obtains a rendering area from Windows Media Player.
    Iwmpnoderealestatehost requests State changes from Windows Media Player.
    Iwmpnodeappswed stores a handle to the parent window used for rendering.
    Iwmpnodeappswedhost sends Windows messages from the plug-in to Windows Media Player.
    Iwmpnodewindowless stores a device context handle used by Windows Media Player when rendering in windowless mode.
    Iwmpnodewindowlesshost provides methods to direct Windows Media Player to update the rendering area in windowless mode.
    Iwmpplugin manages the connection to Windows Media Player.
    Iwmppluginenable stores whether the plug-in is currently enabled by the user.
    Iwmpservices retrieves information from Windows Media Player about the current stream time and stream state.
    Iwmpwindowmessagesink between es messages when in windowless mode.

    Enumeration types and descriptions
    Wmpplugin_caps used with iwmpplugin: getcaps to indicate whether the plug-in can convert between formats.
    Wmpservices_streamstate indicates the whether the stream is currently stopped, paused, or playing.

     

    Author: Wang Kewei
    Source: http://wangkewei.cnblogs.com/
    Copyright: The copyright of this article is shared by the author and the blog. The detailed link of this article must be noted during reprinting; otherwise, the author will reserve the right to pursue its legal liability.
  •  

     

    Media Player Plugins (continued) in Windows Mobile Multimedia Development Summary)

     

    In the article "Media Player Plugins in Windows Mobile Multimedia Development Summary", we summarize several methods for extending WMP (Windows Media Player) in WM (Windows Mobile. After the release, many of my friends asked about the specific practices, so I also summarized the relevant knowledge on the fly, just to make up for my shortcomings in this regard.

    Requirement: in WM development, if you do not develop your own player or use a third-party player, you can only use WMP, but you may need to control WMP in other applications or drivers, or how do I obtain the playback status of WMP? You may want to send messages to the corresponding WMP buttons or simulate keyboard messages. In fact, these are not good solutions. The solution is to use user interface Background plug-ins, which was mentioned in the previous article.

    Knowledge involved: user interface Background plug-ins interface and WMP method to be implemented, compiling of COM in-process servers (extending Microsoft's own software in windows, such as extending IE, in the form of COM), and write today plug-ins. (Of course, it is more convenient to use ATL, so you do not need to implement COM step by step. This is just to gain a deep understanding of the internal principles of COM .)

    [Step 1] develop the position of WMP header files in Aku in Windows Mobile, for example, Aku 6.15 ):

    Use the WMP. h and wmpplug. h header files in your project.

    [Step 2] implement the method required by the server in the com process. This is also the method that needs to be exported in the DLL:
    Dllgetclassobject
    Dllcanunloadnow
    Dllregisterserver
    First, let's take a brief look at the location of the COM server during the creation process. In order to be lazy, the image directly references the VC knowledge base. Component DLL is the COM server to be compiled, and the client is WMP:


    For more knowledge about the principles and usage of COM, refer to "com essence theory" and "in-depth analysis of ATL" (I still know little about ATL/wtl, this book has been on my pillow for a long time, and I have been learning Windows operating systems and learning ATL) or VC knowledge base.

    The above figure explains that when the client calls the cocreateinstance method (this is done by WMP, we don't care), cocreateinstance actually completes the following three steps:
    Cogetclassobject (rclsid, dwclscontext, null, iid_iclassfactory, (void **) & PCF); // This method calls the dllgetclassobject method to be implemented to obtain the pointer of the factory object
    PCF-> createinstance (punkouter, riid, ppvobject); // The cmediaplayerpluginclassfactory: createinstance method is called at this time.
    PCF-> release ();

    Let's take a look at the code of the three methods we want to implement.
    Stdapi dllgetclassobject (refclsid CLSID, refiid riid, void ** GMM)
    {
    Hresult hr;
    Cmediaplayerpluginclassfactory * PCF;

    * GMM = NULL;

    If (PCF = new cmediaplayerpluginclassfactory () = NULL)
    Return e_outofmemory;

    If (failed (hR = PCF-> QueryInterface (riid, PVS) // pass the pointer of the plug-in factory object to WMP
    {
    Delete PCF;
    Return hr;
    }

    Return s_ OK;
    }

    Stdapi dllcanunloadnow ()
    {
    If (g_pserver-> canunload ())
    Return s_ OK;
    Else
    Return s_false;
    }

    Stdapi dllregisterserver () // The system calls this method when you install the plug-in. Here you register your COM server to the CLSID key of the Registry.
    {
    Tchar szmodulepath [max_path];

    // Get our module path.
    If (! Getmodulefilename (getmodulehandle (s_szmodulename), szmodulepath, max_path ))
    Return e_fail;

    Szmodulepath [max_path-1] = _ T ('/0 ');

    // Register this COM object.
    //
    // Important:
    // Be sure to update this GUID with another if you create another plug-in. Each plug-in must have a unique guid.
    Return dllregisterserverimplementation (_ T ("{009b9b8a-5080-4d09-8f74-9bd96a3558d4}"), s_szregdescription, szmodulepath, _ T ("free "));
    }

    Let's take a look at the implementation of cmediaplayerpluginclassfactory. This class implements the iclassfactory interface. Let's take a look at how the most critical method is implemented:

    Hresult cmediaplayerpluginclassfactory: createinstance (iunknown * punkouter, refiid riid, void ** ppvobject)
    {
    Hresult hr;
    Cmediaplayerplugin * pplugin;

    * Ppvobject = NULL;

    If (punkouter! = NULL)
    Return class_e_noaggregation;

    // Create a plug-in object
    If (pplugin = new cmediaplayerplugin () = NULL)
    Return e_outofmemory;

    Pplugin-> internaladdref ();
    HR = pplugin-> finalconstruct (); // register and create a plug-in window here. In fact, this window is invisible and only implements a message loop, it is used by other applications to send messages to it.
    Pplugin-> internalrelease ();

    If (failed (HR ))
    {
    Delete pplugin;
    Return hr;
    }

    If (failed (hR = pplugin-> QueryInterface (riid, ppvobject) // pass the pointer of the plug-in object
    {
    Delete pplugin;
    Return hr;
    }

    Return s_ OK;
    }

    In addition, there are implementations such as the cserver class. For details, see the appendix project.

    Step 3: Implement iwmppluginui and Other interfaces
    Class cmediaplayerplugin:
    Public iwmppluginui

    In the previous article, I listed the methods under this interface:

    Stdmethodimp create (hwnd hwndparent, hwnd * phwndwindow );
    Stdmethodimp destroy ();
    Stdmethodimp displaypropertypage (hwnd hwndparent );
    Stdmethodimp getproperty (lpcwstr wszname, variant * pvarproperty );
    Stdmethodimp setcore (iwmpcore * pcore );
    Stdmethodimp setproperty (lpcwstr wszname, const variant * pvarproperty );
    Stdmethodimp translateaccelerator (MSG * PMSG );

    If you are not interested in implementing these methods, just leave them blank. For example:
    Hresult cmediaplayerplugin: Create (hwnd hwndparent, hwnd * phwndwindow)
    {
    // As per the iwmppluginui documentation, this method will never be called
    // Because we're a background plugin (our registry capabilities flags include
    // Plugin_type_background = 0x00000001 ).

    Return e_notimpl;
    }

    Setcore is a key method, because we need to use it to obtain the interface pointer for WMP operations. Here we store the obtained pointer in m_pcore:
    Hresult cmediaplayerplugin: setcore (iwmpcore * pcore)
    {
    // This method is called shortly after this instance is created, and allows
    // Us to hook up to Windows Media Player. Save the interface pointer.
    //
    // When WMP is shutting down, it CILS setcore (null) so we have to handle that
    // As well.
    If (m_pcore! = NULL)
    {
    M_pcore-> release ();
    }

    M_pcore = pcore;

    If (m_pcore! = NULL)
    {
    M_pcore-> addref ();
    }

    Return s_ OK;
    }

    Then, we can use m_pcore to obtain other interface pointers, such as get_contronls and get_settings. For more details, we can view the attachment project.
    Void cmediaplayerplugin: controlplayer (uint umsg)
    {
    Iwmpcontrols * pcontrols;

    // Get the 'iwmpcontrols' interface.
    If (succeeded (m_pcore-> get_controls (& pcontrols )))
    {
    Switch (umsg)
    {
    // For the toggle message
    Case wm_wmptoggle:
    Wmpplaystate wmpps;

    // Get the current state
    If (succeeded (m_pcore-> get_playstate (& wmpps )))
    {
    // If it playing a track, pause it
    If (wmpps = wmppsplaying)
    {
    Pcontrols-> pause ();
    }
    // Otherwise try to play the track
    Else
    {
    Pcontrols-> play ();
    }

    }
    Break;

    Case wm_wmpprevious:
    Pcontrols-> previous ();
    Break;

    Case wm_wmpnext:
    Pcontrols-> next ();
    Break;

    Default:
    Break;
    }

    Pcontrols-> release ();
    }
    }

    The article was written almost the same as it was last week. It was only published until now. Sorry. In the next article, I will summarize the Development of today plugin. Use the today plugin to control WMP. I hope it will help you. My QQ is 3423 6777 6, if you need any help or discuss it with me.

    The project environment is:
    Win32/Windows Mobile 6 Professional (CHS)/Visual Studio 2008 (CHS)
    /Files/wangkewei/wmplayerplugin.rar

    Author: Wang Kewei
    Source: http://wangkewei.cnblogs.com/
    Copyright: The copyright of this article is shared by the author and the blog. The detailed link of this article must be noted during reprinting; otherwise, the author will reserve the right to pursue its legal liability.
    Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.