locked
Problem with network source property RRS feed

  • Question

  • When I get network source property follow the windows sdk

    sample code, I found some issue with the code:

     

    PROPERTYKEY key;
      key.fmtid = MFNETSOURCE_STATISTICS;
      key.pid = MFNETSOURCE_PROTOCOL_ID;

     

    If I set PROPERTYKEY variable like the code above, I can get a value from IPropertyStore::GetValue().

      

    PROPERTYKEY key;
      key.fmtid = MFNETSOURCE_PROTOCOL;
      key.pid = 0;

     

    But if I set PROPERTYKEY variable like the code above, I can not get the value from IPropertyStore::GetValue().

     

    The two IPropertyStore pointers are the same and queryed from IMFMediaSource pointer, also, the codes are both provided by windows sdk, why one can work well but the other not?

     

    Did anyone met this problem, and can anyone do me a favor?

    thanks a lot!

    Monday, April 12, 2010 11:10 AM

Answers

  • Apparently the HTTP bytestream does not honor the MFNETSOURCE_CACHEENABLED property as I had thought.  The only way to disable caching is to include the parameter WMCache=0 as a parameter for the URL (that is, http://www.blah.com/movie.m4v?WMCache=0)

    If buffering is enabled at all, the buffering time is only used as a recommendation and not as a hard limit.  If you want to mandate that the buffering time be used as a hard limit, you can set the MFNETSOURCE_PREVIEWMODEENABLED property to VARIANT_TRUE.  This could result in a poor playback experience, as without enough data the bytestream may have to regularly go into a buffering state.

    Wednesday, June 2, 2010 12:32 AM

All replies

  • Some netsource properties are read-only, as they are properties that correspond to the actual properties of the connected stream.  For example, MFNETSOURCE_PROTOCOL corresponds directly to the protocol (HTTP, RTSP, MULTICAST) that is being used to communicate with the server.  You cannot set this property because there is no way to change the protocol used to connect to the server once connected.

    You can set MFNETSOURCE_PROTOCOL_ID because this property is not exposed by the netsource itself.  In order to retrieve this property, you must use the netsource statistics service.  This property will also be read only if you use it with the statistics property store.

    Tuesday, April 13, 2010 5:36 PM
  • Thanks for your reply.

    But if the netsource properties are read only, why I cannot get the netsource properties?

    Also, the media foundation SDK document said that we can use MFNETSOURCE_PROTOCOL to get the protocol, but the sample code didnot work correctly, why?

    Is there anything wrong with the media foundation sdk document or the sample code? 

    Wednesday, April 14, 2010 12:14 PM
  • pSourceResolver->CreateObjectFromURL(L"rtsp://WINDOWS_MEDIA_SERVER/video.wmv", ..., &pSourceUnk);
    
    CComPtr<IPropertyStore> spStore;
    pSourceUnk->QueryInterface(IID_PPV_ARGS(&spStore));
    
    PROPERTYKEY key;
    key.fmtid = MFNETSOURCE_PROTOCOL;
    key.pid = 0;
    PROPVARIANT varResult = {};
    spStore->GetValue(key, &var);

    So you are saying you are doing something like this, and not getting back a result in the PROPVARIANT?  I do not see why this would not work.  You should make sure you are using the netsource for streaming using MS-WMSP or MS-RTSP and not just doing an HTTP download.  HTTP downloads do not use the netsource.

     

    Wednesday, April 28, 2010 8:32 PM
  • Thanks to your reply!

    The URL is like http://www.***.com/*.m4v, I donot known whether the server exactly followed the MS-WMSP. But I can use "MFNETSOURCE_STATISTICS" and "MFNETSOURCE_PROTOCOL_ID" to get the protocal type which is "MFNETSOURCE_HTTP", and there are also buffer and cache state while playing.

    If the Media Foundation donot use netsource to play the above URL, how do I control the buffer size and disable the cache feature?

    Thanks a lot. 

    Friday, April 30, 2010 5:38 AM
  • That looks like an HTTP progressive download URL -- the network source does not support streaming of MP4 content at the moment.  The HTTP progressive download bytestream does not support the MFNETSOURCE_PROTOCOL property, but it does support MFNETSOURCE_PROTOCOL_ID.  It does not allow disabling buffering or cache on the fly.  However, when you call the source resolver you can pass in an IPropertyStore containing configuration parameters.  If you set MFNETSOURCE_CACHEENABLED to false it will disable caching and if you set MFNETSOURCE_BUFFERINGTIME to 0 it will disable buffering.  This applies to the entire duration of streaming.

    Tuesday, May 11, 2010 10:56 PM
  • I create a simple web site using IIS, when I play the content on  my site, it is the same as playing the content on that server. Does this prove that server URL is an HTTP progressive download URL?

    >"It does not allow disabling buffering or cache on the fly.  However, when you call the source resolver you can pass in an >IPropertyStore containing configuration parameters.  If you set MFNETSOURCE_CACHEENABLED to false it will disable caching and if >you set MFNETSOURCE_BUFFERINGTIME to 0 it will disable buffering."

    I does not completely understand your words, did you mean that I can set MFNETSOURCE_CACHEENABLED false to disable caching and set MFNETSOURCE_BUFFERINGTIME 0 to disable buffering when I play that server's content? I had set MFNETSOURCE_CACHEENABLED to false and set MFNETSOURCE_BUFFERINGTIME to 0, but the caching and buffering is still working?

    Thursday, May 20, 2010 2:39 PM
  • Yes, if you are just using a regular IIS server without any Windows Media Server extensions, that is HTTP progressive download.

    When setting the properties for the HTTP bytestream, querying the source for IPropertyStore does not work for setting the properties.  You must create a property store, set the cache and buffering properties, and pass this property store to the source resolver when calling BeginCreateObjectFromURL or CreateObjectFromURL.  A rough example: 

    CComPtr<IPropertyStore> spConfigStore;
    PSCreateMemoryPropertyStore(IID_PPV_ARGS(&spConfigStore));
    
    PROPERTYKEY key = {};
    key.fmtid = MFNETSOURCE_CACHEENABLED;
    key.pid = 0;
    
    PROPVARIANT var = {};
    var.vt = VT_I4;
    var.lVal = 0;
    
    spConfigStore->SetValue(key, var)
    
    CComPtr<IMFSourceResolver> spResolver;
    MFCreateSourceResolver(&spResolver);
    
    MF_OBJECT_TYPE MFObjType;
    CComPtr<IUnknown> spSrcUnk;
    
    spResolver->CreateObjectFromURL(L"http://www.blah.com/movie.m4v", MF_RESOLUTION_MEDIASOURCE, spConfigStore, &MFObjType, &spSrcUnk);
    Tuesday, May 25, 2010 11:14 PM
  • I am really appreciate your patiently reply, but the result is not completely as you said.

    I set MFNETSOURCE_CACHEENABLED to 0 as your codes when calling BeginCreateObjectFromURL, but I still can use MFNETSOURCE_CACHE_STATE_ID to get the cache state which is MFNETSOURCE_CACHE_ACTIVE_WRITING, and I can get the cache file from the IE temporary folder. Why?

    I set MFNETSOURCE_BUFFERINGTIME to 0, and the value of the MFNETSOURCE_BUFFERSIZE_ID is always 0 when I set a new playback position. But if I set MFNETSOURCE_BUFFERINGTIME to 1(second or million second?), the value of the  MFNETSOURCE_BUFFERSIZE_ID is mostly greater than 2000. It seems that I can disable the buffering management but can not set the buffering size. How do I set the buffering size? Thanks a lot.

    Friday, May 28, 2010 5:20 AM
  • Apparently the HTTP bytestream does not honor the MFNETSOURCE_CACHEENABLED property as I had thought.  The only way to disable caching is to include the parameter WMCache=0 as a parameter for the URL (that is, http://www.blah.com/movie.m4v?WMCache=0)

    If buffering is enabled at all, the buffering time is only used as a recommendation and not as a hard limit.  If you want to mandate that the buffering time be used as a hard limit, you can set the MFNETSOURCE_PREVIEWMODEENABLED property to VARIANT_TRUE.  This could result in a poor playback experience, as without enough data the bytestream may have to regularly go into a buffering state.

    Wednesday, June 2, 2010 12:32 AM
  • Thanks, using MFNETSOURCE_PREVIEWMODEENABLED and MFNETSOURCE_BUFFERINGTIME properties can control the buffering size. but the value of the MFNETSOURCE_BUFFERINGTIME property is million second, not the second as MSDN said.

    When I set MFNETSOURCE_PREVIEWMODEENABLED property to VARIANT_TRUE, there are so muchissue while playing. It maybe keep playing while the video is a static picture. The player maybe stop before the end of the content sometimes.

    When I do not use MFNETSOURCE_PREVIEWMODEENABLED property, It seems that the buffering management considered the bandwidth between the client and the server to decide the buffering size. It will buffer half of the content if the link speed too slow.

    Thursday, June 3, 2010 6:22 AM
  • I have the same problem.i am unable to control the buffering size.In the above reply i can see MFNETSOURCE_PREVIEWMODEENABLED and MFNETSOURCE_BUFFERINGTIME properties can control the buffering size. how  i can set two property in one time,in one time i set one property but it is not helpful.

           PROPERTYKEY key = {};
    key.fmtid = MFNETSOURCE_PREVIEWMODEENABLED ;
    key.pid = 0;

    PROPVARIANT var = {};
    var.vt = VARIANT_TRUE;
    var.lVal = 0;

    ppropstore->SetValue(key, var);

    1)how i can use MFNETSOURCE_BUFFERINGTIME  property to set buffering time 2 sec or so with above MFNETSOURCE_PREVIEWMODEENABLED property ??

      ppropstore is am getting in BeginCreateObject(LPCWSTR pwszURL, DWORD dwFlags, IPropertyStore *ppropstore, IUnknown **ppIUnknownCancelCookie, IMFAsyncCallback *pCallback, IUnknown *punkState);

    2)do in need to create propertyStore pointer or i can use the same that i receive in BeginCreateObject??

    Friday, June 12, 2015 9:52 AM
  • Hi Matt,

    1. I am unable to create Property Store using PSCreateMemoryPropertyStore(IID_PPV_ARGS(&spConfigStore));

    It says undefined reference , but I have this header file PropSys.h where I can find declaration of above function.

    2. How to set more than one property in Property store?

    Thanks

    Shailesh Khare

    Friday, June 12, 2015 11:25 AM