Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Tuesday, June 26, 2007 5:38:10 AM(UTC)

joseph  
joseph

Groups: Registered
Posts: 10


Hi,

I am using the DirectShow Filter Graph with the ltmm try to play a video streaming file from your video site, but it can only play either video or audio. First, I can play the video (no audio) very well by using below code:

Declaration of the CLSID:  static const GUID CLSID_LMNetSrc =
{ 0xE2B7DE03, 0x38C5, 0x11D5, { 0x91, 0xF6, 0x00, 0x10, 0x4B, 0xDB, 0x8F, 0xF9 } };

Code To play the video streaming:

   HRESULT Result;

   IBaseFilter* pFilterSource = NULL;
   IBaseFilter* pFilterDestination = NULL;

   IPin* pPinSrc = NULL;
   IPin* pPinDst = NULL;

   Result = CoCreateInstance(CLSID_LMNetSrc, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**) &pFilterSource);

   if (SUCCEEDED(Result) && pFilterSource != NULL)
   {
    IFileSourceFilter* pFileSource = NULL;
    Result = pFilterSource->QueryInterface(IID_IFileSourceFilter, (void**)&pFileSource);
    if (pFileSource != NULL)
    {
     Result = pFileSource->Load(UTF8_To_UTF16(URL).c_str(), NULL);
     SafeRelease(pFileSource);
    }

    Result = mpGraphBuilder->AddFilter(pFilterSource, UTF8_To_UTF16(URL).c_str());
   }

   std::string Extension(ToLower(GetFileExtension(URL)));

   int PinIndex = 0;
   while (FindOutputPinByIndex(pFilterSource, PinIndex, &mpPinVideoSource) == S_OK)
   //if (FindOutputPinByIndex(pFilterSource, PinIndex, &mpPinVideoSource) == S_OK)
   {
    bool IsVideo = false;

    AM_MEDIA_TYPE* pMediaType = NULL;
    IEnumMediaTypes* pEnumMediaTypes = NULL;
    mpPinVideoSource->EnumMediaTypes(&pEnumMediaTypes);

    if (pEnumMediaTypes != NULL)
    {
     while (IsVideo == false && pEnumMediaTypes->Next(1, &pMediaType, NULL) == S_OK)
     {
      if (pMediaType->majortype == MEDIATYPE_Video || pMediaType->majortype == MEDIATYPE_Stream)
      {
       IsVideo = true;
      }

      DeleteMediaType(pMediaType);
      pMediaType = NULL;
     }
    }
    SafeRelease(pEnumMediaTypes);

    if (IsVideo == false)
    {
     ++PinIndex;
     SafeRelease(mpPinVideoSource);
    }
    else
    {
     break;
    }
   }

   SafeRelease(pFilterSource);
   if (mpPinVideoSource != NULL) // && SUCCEEDED(mpPinVideoSource->ConnectedTo(&pPinDst))
   {
    mpSyncFilter = new c_SyncFilter("Sync Filter", &Result);
    mpGraphBuilder->AddFilter(mpSyncFilter, L"Sync Filter");
    IPin* pPin = NULL;
    if (FindInputPinByIndex(mpSyncFilter, 0, &pPin) == S_OK)
    {
     Result = mpGraphBuilder->Connect(mpPinVideoSource, pPin);
     //SafeRelease(pPin);

     if (FindOutputPinByIndex(mpSyncFilter, 0, &pPin) == S_OK)
     {
      std::swap(mpPinVideoSource, pPin);
      SafeRelease(pPin);
     }

    }

    if (FindAudioOutputPinByIndex(mpFilterGraph, 0, &pPinSrc) == S_OK)
    {
     mpGraphBuilder->Render(pPinSrc);
    }

    SafeRelease(pPinSrc);

    Result = mpGraphBuilder->QueryInterface(&(mpBasicVideo));
    Result = mpGraphBuilder->QueryInterface(&(mpMediaControl));
    Result = mpGraphBuilder->QueryInterface(&(mpMediaEvent));
    Result = mpGraphBuilder->QueryInterface(&(mpMediaSeeking));
    Result = mpGraphBuilder->QueryInterface(&(mpMediaEventSink));
    Result = mpGraphBuilder->QueryInterface(&(mpMediaPosition));
    Result = FindFilterInterfaceByIndex(mpFilterGraph, 0, IID_IQualProp, (void**)&(mpQuality));
    Result = FindFilterInterfaceByIndex(mpFilterGraph, 0, IID_IBasicAudio, (void**)&(mpBasicAudio));

    IMediaFilter* pMediaFilter = NULL;
    mpFilterGraph->QueryInterface(IID_IMediaFilter, (void**)&pMediaFilter);
    if (pMediaFilter != NULL)
    {
     SafeRelease(mpReferenceClock);
     mpReferenceClock = GetSystemClock();
     if (mpReferenceClock != NULL)
     {
      pMediaFilter->SetSyncSource(mpReferenceClock);
      mSyncFileTime = gpTimeManager->LocalTimeAsFileTime();
      mSyncPerformance = gpTimeManager->PerformanceTimeAsInt64();
      mpReferenceClock->GetTime(&mSyncReference);

      IAMClockAdjust* pClockAdjust = NULL;
      mpReferenceClock->QueryInterface(IID_IAMClockAdjust, (void**)&pClockAdjust);
      if (pClockAdjust != NULL)
      {
       SafeRelease(mpClockAdjust);
       mpClockAdjust = pClockAdjust;
      }
     }
     else
     {
      SafeRelease(mpReferenceClock);
      pMediaFilter->GetSyncSource(&mpReferenceClock);
     }
    }
    SafeRelease(pMediaFilter);

    return true;
   }
   else
   {
    return false;
   }

When I added the green and red part of code, the audio comes out well, but the video will go bad.  So, for now, I can only either play the video or the audio, but not both.  This happen even I copy the video file to local drive to play.  However, I can always play well with other video files, such as mpeg or wmv, with these code. 

Can anyone tell me how to get the video and audio play well together? Any Idea?

Thanks in advance.

 

 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Tuesday, June 26, 2007 5:42:04 AM(UTC)

joseph  
joseph

Groups: Registered
Posts: 10


Seems like the Font color won't show in the posted message.

The green and red part of code is below:

    mpSyncFilter = new c_SyncFilter("Sync Filter", &Result);
    mpGraphBuilder->AddFilter(mpSyncFilter, L"Sync Filter");
    IPin* pPin = NULL;
    if (FindInputPinByIndex(mpSyncFilter, 0, &pPin) == S_OK)
    {
     Result = mpGraphBuilder->Connect(mpPinVideoSource, pPin);  //Red Color Font
     //SafeRelease(pPin);

     if (FindOutputPinByIndex(mpSyncFilter, 0, &pPin) == S_OK)
     {
      std::swap(mpPinVideoSource, pPin);
      SafeRelease(pPin);
     }

    }

    if (FindAudioOutputPinByIndex(mpFilterGraph, 0, &pPinSrc) == S_OK)
    {
     mpGraphBuilder->Render(pPinSrc);
    }

    SafeRelease(pPinSrc);

 

Thanks

 
#3 Posted : Tuesday, June 26, 2007 11:30:45 PM(UTC)

Qasem Lubani  
Guest

Groups: Guests
Posts: 3,028

Was thanked: 2 time(s) in 2 post(s)


Joseph,


Since the same behavior happens
when you play the file from local disk, the problem is likely not related to
the LEAD network components. Also, if you try to play the video using Windows
Media Player or our toolkit Player demos, and it plays correctly, this will indicate the problem is not caused by your system (hardware or drivers).


 


In that case, you can modify
our Player demo and add a call to the EditGraph function, which will show you how our toolkit builds the graph internally.


 


If the problem turns out to be related to MS
DirectShow SDK programming, I'm afraid we won't be able to help you much, because our experience is mainly using our own multimedia toolkit.
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2020, Yet Another Forum.NET
This page was generated in 0.203 seconds.