Announcement

Collapse
No announcement yet.

Media Foundation MediaPlayer

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Media Foundation MediaPlayer

    Hi Jose',
    Which include/s covers the MediaPlayer functions? I've looked in these...

    \mfapi.inc
    \Mferror.inc
    \mfidl.inc
    \mfmp2dlna.inc
    \mfobjects.inc
    \mfreadwrite.inc
    \mftransform.inc
    \unknwn.inc
    \propsys.inc
    \mediaobj.inc
    \mmreg.inc
    \mmsystem.inc
    \windows.inc
    \objidl.inc
    \oleidl.inc
    \ocidl.inc
    \shtypes.inc
    \StructuredQueryCondition.inc
    \wtypes.inc
    \oaidl.inc
    \windef.inc
    \amvideo.inc
    \dvdmedia.inc
    \strmif.inc
    \sdkddkver.inc
    \ddraw.inc
    \WINNT.INC
    \ole2.inc
    \basetsd.inc
    \guiddef.inc
    \propidl.inc
    \servprov.inc
    \urlmon.inc
    \msxml.inc
    \winerror.inc
    \objbase.inc
    \oleauto.inc
    \basetsd.inc
    \guiddef.inc
    \ntstatus.inc
    \ktmtypes.inc

    Thanks

  • #2
    What do you want? Media Foundation or Windows Media Player?

    Media Foundation: The ones that start with "mf", and specially "mfapi.inc".

    Windows Media Player: The ones that start with "wmp", and specially "wmp.inc".
    Forum: http://www.jose.it-berater.org/smfforum/index.php

    Comment


    • #3
      Yes Thank you,

      I'm only interested in playback so I guess I should be looking at IMFMediaSession. I've used WMP via active x but have been disappointed with its memory leak so now I am pursuing MF to get direct control of playback and clearing resources completely between track playback. All I need to play is WMA, MP3, and M4A.

      Comment


      • #4
        Jose'

        I am looking for the IID_PPV_ARGS macro. MSDN says it is in the Objbase.h. As yet I have not found it in the Objbase.inc. Any ideas?
        MSDN says it is this:

        void
        IID_PPV_ARGS(
        T **pType
        );

        I'm having trouble interpreting that.
        Thank you.

        Comment


        • #5
          This macro can't be translated to PB because it is designed to work with C++ templates. It's only purpose is to avoid C++ casting warnings and it is not needed at all with PB.
          Forum: http://www.jose.it-berater.org/smfforum/index.php

          Comment


          • #6
            Hmm,
            So
            hr = ppObject.QueryInterface($IID_IUnknown, IID_PPV_ARGS(ppObject))

            would be replaced with something like this:

            hr = ppObject.QueryInterface($IID_IUnknown, ppObject)
            ?

            Is the QueryInterface unnecessary as well?

            This is what I have translated...


            Code:
            FUNCTION CreateMediaSource( _
                BYREF pwszURL AS WSTRINGZ, _
                BYVAL pProps AS IPropertyStore, _   '// Optional, can be NULL
                BYREF ppSource AS IMFMediaSource) AS LONG
            
                LOCAL hr AS LONG
                LOCAL pSourceResolver AS IMFSourceResolver
                'IMFSourceResolver* pSourceResolver = %NULL
                LOCAL ppObject AS IUNKNOWN
                'IUNKNOWN* pSource = %NULL
            
                '// Create the source resolver.
                hr = MFCreateSourceResolver(pSourceResolver)
            
                '// Use the source resolver to create the media source.
                IF SUCCEEDED(hr) THEN
                    LOCAL pObjectType AS LONG 'MF_OBJECT_TYPE
                    'MF_OBJECT_TYPE ObjectType
            
                    ? "CreateObjectFromURL"
            
                    hr = pSourceResolver.CreateObjectFromURL( _
                        pwszURL, _                    ' __in LPCWSTR pwszURL             '//
                        %MF_RESOLUTION_MEDIASOURCE, _ ' __in DWORD dwFlags               '// Create a media source.
                        pProps, _                     ' __in IPropertyStore *pProps      '// Configuration properties.
                        pObjectType, _                ' __out MF_OBJECT_TYPE *pObjectType'// Receives the object type.
                        ppObject)                     ' __out IUnknown **ppObject        '//
            
                    ? "CreateObjectFromURL - FINISHED"
            
                END IF
            
                IF SUCCEEDED(hr) THEN
                    'hr = pSource.QueryInterface($IID_IUnknown, IID_PPV_ARGS(ppObject))
                    hr = ppObject.QueryInterface($IID_IUnknown, ppObject)
                END IF
            
                SafeRelease(pSourceResolver)
                SafeRelease(ppObject)
                FUNCTION = hr
            END FUNCTION

            Comment


            • #7
              Yes, I know I'm lost.

              Comment


              • #8
                > would be replaced with something like this:
                > hr = ppObject.QueryInterface($IID_IUnknown, ppObject)

                Yes.

                > Is the QueryInterface unnecessary as well?

                With PB, yes. In the posted code, I don't understand why you are calling it. There must be something in the original code that is missing in what you have posted.

                I also don't understand why you're passing pProps. Pass NOTHING.
                Forum: http://www.jose.it-berater.org/smfforum/index.php

                Comment


                • #9
                  Jose',

                  I really need some help here. I'm pretty sure I need a pointer to a pointer as ppMediaSession but I have been unable to get the function to accept anything other than pMediaSession. As it currently is with pMediaSession for the value the hr is -1072873851


                  Code:
                  DECLARE FUNCTION MFCreateMediaSession IMPORT "mf.dll" ALIAS "MFCreateMediaSession" ( _
                     BYVAL pConfiguration AS IMFAttributes _              ' __in  IMFAttributes* pConfiguration
                   , BYREF ppMediaSession AS IMFMediaSession _            ' __out IMFMediaSession** ppMediaSession
                   ) AS LONG                                              ' HRESULT
                  
                  
                  FUNCTION OpenTheURL(BYREF pwcsURL AS WSTRINGZ) AS LONG
                      '? pwcsURL
                      CALL MFStartup(%MF_API_VERSION, 0)
                  
                      '// 1. Create a new media session.
                      '// 2. Create the media source.
                      '// 3. Create the topology.
                      '// 4. Queue the topology [asynchronous]
                      '// 5. Start playback [asynchronous - does not happen in this method.]
                  
                      LOCAL pMediaSession      AS IMFMediaSession
                      LOCAL pTopology          AS IMFTopology
                      LOCAL pSourcePD          AS IMFPresentationDescriptor
                      LOCAL pMediaSource       AS IMFMediaSource
                      LOCAL pCallback          AS IMFAsyncCallback
                      LOCAL pConfiguration     AS IMFAttributes
                  
                      LOCAL hr          AS LONG
                  
                      hr = MFCreateMediaSession(pConfiguration, pMediaSession)
                      ? STR$(hr)  'All I get is -1072873851
                                  'if created it should be %S_OK or 0
                  done:
                  END FUNCTION
                  
                  

                  Comment


                  • #10
                    In my computer it returns 0 (%S_OK).

                    Code:
                    #COMPILE EXE
                    #DIM ALL
                    #INCLUDE ONCE "windows.inc"
                    #INCLUDE ONCE "mfapi.inc"
                    #INCLUDE ONCE "mfidl.inc"
                    
                    FUNCTION PBMAIN () AS LONG
                    
                       LOCAL hr AS LONG
                       hr = MFStartup(%MF_API_VERSION, 0)
                    
                       ? HEX$(hr)
                    
                        LOCAL pMediaSession      AS IMFMediaSession
                        LOCAL pConfiguration     AS IMFAttributes
                    
                       hr = MFCreateMediaSession(pConfiguration, pMediaSession)
                       ? HEX$(hr)
                    
                       MFShutdown
                    
                    END FUNCTION
                    Forum: http://www.jose.it-berater.org/smfforum/index.php

                    Comment


                    • #11
                      Hmm, yes your DDT example works fine here too. But when I run the same exact steps in my SDK version I get FFFFFFFFC00D3E85. Weird.

                      Ahh, I think I found the problem. The SDK app I had cobbled together for building and testing the Media Player apparently had some issues.
                      My Bad.

                      Thank you very much!

                      Comment


                      • #12
                        Just for curiosity, MF_E_SHUTDOWN looks like a good candidate for the issues you had...

                        ErrorCode = -1072873851 = 0xC00D3E85 = MF_E_SHUTDOWN = The request is invalid because Shutdown() method has been called. (IMFMediaSession)

                        https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx
                        MFCreateMediaSession: pConfiguration- Pointer to the IMFAttributes interface. This parameter can be NULL.
                        ppMS- Receives a pointer to the Media Session's IMFMediaSession interface. The caller must release the interface. Before releasing the last reference to the IMFMediaSession pointer, the application must call the IMFMediaSession::Shutdown method.

                        https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx
                        IMFMediaSession::Shutdown method: Call this method when you are done using the Media Session, before the final call to IUnknown::Release.After this method is called, other IMFMediaSession methods return MF_E_SHUTDOWN.

                        Comment


                        • #13
                          Hmm funny thing is that I only get this error on one crappy SDK test app.

                          And this was the problem for that one app...

                          Code:
                          FUNCTION MFStartup(BYVAL Version AS DWORD, BYVAL dwFlags AS DWORD) AS LONG
                          END FUNCTION
                          I had it mixed in with my declares. Silly me. That's the kind of mistakes you make in a test app.

                          Comment


                          • #14
                            What
                            DDT ?

                            ..
                            Dale

                            Comment


                            • #15
                              The test app is SDK. Now my primary SDK, my test app SDK, and Jose' DDT example all create a Media Foundation Session. Thank GOD.

                              Comment


                              • #16
                                Maybe you mean PB example. There is no DIALOG NEW, nor CONTROL ADDs, so no DDT.

                                Cheers,
                                Dale

                                Comment


                                • #17
                                  Originally posted by Dale Yarker View Post
                                  Maybe you mean PB example. There is no DIALOG NEW, nor CONTROL ADDs, so no DDT.

                                  Cheers,
                                  While I agree that we don''t see any "DDT commands" in this thread Bob included a number of statements other than DIALOG... and CONTROL... in the "DDT" category. See "Dynamic Dialog Tool Commands" in Help.

                                  CLIPBOARD..., DESKTOP..., DISPLAY....,, INPUTBOX$ come to mind

                                  Comment


                                  • #18
                                    A simple PBMAIN does not make a program to be DDT. It is just a shortcut for WinMain.

                                    Code:
                                    #COMPILE EXE
                                    #DIM ALL
                                    #INCLUDE ONCE "windows.inc"
                                    #INCLUDE ONCE "mfapi.inc"
                                    #INCLUDE ONCE "mfidl.inc"
                                    
                                    FUNCTION WinMain (BYVAL hInstance AS DWORD, BYVAL hPrevInstance AS DWORD, BYVAL lpszCmdLine AS WSTRINGZ PTR, BYVAL nCmdShow AS LONG) AS LONG
                                    
                                       LOCAL hr AS LONG
                                       hr = MFStartup(%MF_API_VERSION, 0)
                                    
                                       LOCAL pMediaSession AS IMFMediaSession
                                       hr = MFCreateMediaSession(NOTHING, pMediaSession)
                                       ? HEX$(hr)
                                    
                                       MFShutdown
                                    
                                    END FUNCTION
                                    Forum: http://www.jose.it-berater.org/smfforum/index.php

                                    Comment


                                    • #19
                                      "An elephant is gray, but not everything that is gray is an elephant." unknown (by me at least)

                                      DDT is part of PB (Win), but not all of PB is DDT.
                                      While I agree that we don''t see any "DDT commands" in this thread Bob included a number of statements other than DIALOG... and CONTROL... in the "DDT" category. See "Dynamic Dialog Tool Commands" in Help.
                                      Did I have to list them all to avoid your comment?

                                      ((I see Jose has posted. You triggered none of this.))
                                      Dale

                                      Comment


                                      • #20
                                        All,
                                        I stand corrected. 2 SDK style and 1 plain jane style are working as expected.

                                        Comment

                                        Working...
                                        X