Welcome to MSDN Blogs Sign in | Join | Help

A ticket without solution and workaround

not actually an official blog
Two issues about core audio and media foundation

1. If your application is based on Vista core audio and replies on DEVICE_STATE_DISABLED flag, you may encounter issue. There is no core audio API/flag can be used to replace. An ugly and unsupported workaround is to check/monitor some registry keys. This workaround may be broken after core audio is updated.

2. When index of ASF source is not available, Meida Foundation uses approximate seek automatically. It may cause long time delay. One obvious symptom is if you move the progress bar of Windows Media Player11(Vista version) to a random back position when playing back wma file, you may find the actual position is not the position you tried to set. It's a limitation. Currently, there is no way to get around it in MF.

They will be fixed and improved.

Socket 10055 error

10055 error is a very "common" socket error if you write socket application. On NT platform, generally speaking, the reason why this error occurs is because non-paged pool memory is almost used up.

 Before you use performance monitor to check non-paged pool memory usage, there are several simple things that you might want to check first:

 1. The default maximum number of ephemeral TCP ports. The default value is 5000, if you find your socket application needs more than 5000 ports, please increase the value. Here is a KB article which shows how/where to change it.

 2. If your application is based on .NET 1.1, please make sure you've installed .NET 1.1 SP1. There is a known issue which was fixed in 1.1 SP1.

 3. The number of network protocol is less than 50.  

 

 

TransmitFile takes long time to send data

How long? haf day or maybe one day. You may encounter the symptom when calling TransmitFile to send a file from one socket to another socket.  There are many possible reasons may make TransmitFile hang, before you capture kernel dump, update NIC driver, close firewall, remove 3rd party LSP, remove network filter driver, you might want to check one simple setting in the first place:

1. Open device manager

2. Expand the tree and go to NIC node

3. Open "properties" of the NIC device

4. Find "Speed and Duplex" settings in "advance" tab, check whether it is "auto". If not, change it back to auto

5. Test your program again

 

Application which hosts Windows Media Player OCX may not be able to fully quit

You may be occasional encounter such symptom: your window based application that hosts a WMP OCX control does not fully quit after you close the window. The window got disappear successfully, but you still can find the process running in task manager. If you're playing something in Windows Media Player 11 and you still can hear music after you close it, this is not the same story that I wanted to tell, you may want to read this KB.

If you attach a debugger to the "phantom" process, and check the call stack of the main thread, you will be finding it's still in the message loop of the main window. What happened? Since you clicked the exit button, the message loop should had been quitted. Does this mean system forgot to send WM_QUIT to the application? It's not so complicated, just a very simple reason, the main window did not receive the WM_QUIT message. How could it happen? There is a message pump and there is some code to handle different return value of GetMessage. In the own WMP OCX host window code, you also called PostQuitMessage in the WM_DESTORY. You may also consulted WMPHOST sample which ships with WMP SDK. You cannot find main difference between your code and the sample code. But WMPHOST just works fine on your machine.

The symptom only happens with WMP 10 or eariler. Yes, it's a bug and had been fixed in WMP11. But why only your application suffers the pain, does Microsoft use any magic in WMPHOST sample? There is no magic. The solution is to handle WM_NCDESTORY. Because when WMP OCX receives WM_QUIT, it eats the message and does not post to other window of the thread, so the main window may never know it needs to quit. You can handle WM_NCDESTORY in the OCX host window's code, call PostQuitMessage in it and it will post the quit message to the main window inerrably. If you look WMPHOST code carefully, you'll find it just use this way to get around the bug.

This symptom may not always happens if the main window receives WM_QUIT message before WMP OCX messge pump eats it.

 

Silent license acquisition not working

There are two kinds of license acquisition mechanism in MS DRM: silent and non-silent. If content providers implement both of them in DRM license server application, Windows Media Player should go silent mode first as long as automatically downloads usage rights option is enabled. It switches to non-silent mode when silent mode gets failed.

 

If you’re content provider and gets some complains from the users which is about silent mode does not work, you might want to check two things:

 

1.       When you package the content, make sure you use a correct URL string of license server. The URL string is a HTTP address (http://xxxx), sometimes, the string may be changed to “http:\\xxx” by mistake or other reasons. This will make silent license acquisition failed but non-silent will still be working. WMP's non-silent related module internally checks the string format and corrects it if it’s incorrect. This is a good and makes application robust, but it makes troubleshooting become hard. Because non-silent mode works, people may not suspect the license server URL string is incorrect, and pay more attention to other stuff. Checking the license server URL string is pretty easy, you could review code or just open a DRM’d file in ASFViewer, you can find the string in the head.

 

2.       If the license server application is developed by ASP.NET, ASP.NET may add some HTML tags in HTTP response string. These tags are invisible to developers and will confuse WMP9’s XML parser. To get around it, you might want to write code like below:

 

Response.Clear();

Response.Write(liccenseresponse);

Response.Flush();

Response.End();

       

      Windows Media Player 10/11 do not have this issue because of the XML parser is different.

AVIFileOpen changed on Vista

You may find your legacy program failed on calling AVIFileOpen when it is trying to open a custom AVI file on Windows Vista. The returned COM error is -2147205011(0x8004406D). But the program works fine on WinXP when opening same AVI file.

If you're the owner of the AVI file, you might want to check your AVI file's header data. You might write incorrect Bitmap header info data or something into the AVI file.

On Vista, AVIFileOpen calls ValidateBitmapInfoHeader internally to validate the source AVI file's bitmap header info; Some custom AVI files may not need a correct bitmap header for decoding and playback. This is not a problem on XP because XP's AVIFileOpen does not call this DShow helper function.

Since this is an inline C++ function, you can read the source in DirectShow SDK's header file.

A glance at WMS9.5's cache proxy plug-in

It's time to try the built-in cache proxy plug-in of WMS9.5. If you already developed custom proxy cache plug-in for WMS9.1, you also can install it on WMS9.5 and the plug-in should be working fine as well. But you might want to test whether the own plug-in can conflict with the built-in plug-in if you enable both of them.

The plug-in can be enabled from WMS9.5 admin MMC / root node (machine name) / Properties / Cache Proxy Management / WMS Cache Proxy:

 

WMS_CACHEPlugin

Double click the plug-in, its property window will show up. In general tab page, you can check the status of the plug-in and type of the plug-in is acting. It could be a standard proxy, proxy redirect and reverse proxy.

You can find the details of every type of proxy from Platform 2003 SDK, for example: Implement Reverse Proxy

In the cache tab page, you can set caching speed. Set it to maximum available bandwidth if you don't have any concern about it. In case you want to manually set a value, just don't set it too small.

In proxy tab page, you can set the type of the cache proxy and the content server/alternate proxy's location. Currently, the plug-in only support one server.

If you want the plug-in starts the streaming content rather than first downloading it, you might want to configure it in prestuff tab page. It can prestuff from stream or file.

In order to test the plug-in, you should prepare another WMS machine which acts as content server or alternative proxy. Make the WMS 9.5's proxy plug-in point to that server. Create a publishing point named proxytest on the content server, the client machine, open Windows Media Player to access mms://proxyserver/proxytest. If you configured everything correctly in the proxy plug-in, it will download proxytest's content from the content server automatically when the first time you access the link. If you configured prestuff in the plug-in, the plug-in should download it itself even if you don't access the link.

To sum up, your old proxy cache plug-in which was developed for WMS 9 should still be able to be installed on WMS9.5 but you should test it to check whether it will conflict with WMS9.5's. Every features of the built-in proxy plug-in of WMS9.5 should be very easy to use if you have already known and used WMS9's proxy plug-in programming model. I strongly recommend you to read related documents in platform SDK to better understand how does proxy plug-in work.

Incorrect wma presentation time

ASFView may complain some audio samples’ presentation time is incorrect if you open an ASF file using it. There are many different reasons can cause incorrect presentation time issue, if you wrote own encoder application based on Format SDK, you may take a look this case:

 

Does the encoder re-package audio sample? One scenario could be the encoder read wma samples from source by using Format SDK and combine some of them into a big buffer as a sample for some reasons. How does the encoder calculate presentation for the re-packaged sample? Every wma sample read from source has a presentation stamp, when the encoder combines them into one sample, what’s the presentation time it assigns to the combined sample?

 

I didn’t really see the case I described above, I just found some encoders calculate incorrect presentation time and it looks like those encoders need to re-package wma sample and/or re-encode wma samples. Below is a workaround in pseudo code may help to get around the problem, but I cannot guarantee it always works. If anyone wrote an encoder and encounter similar incorrect presentation time issue and my workaround isn’t helpful, I’d like to take a look.  

 

Note, the workaround is only for wma sample, if the problem you actually encounter is wmv sample, please DON'T USE the workaround.  

 

var1 = 0;

buffer_sample_size = pBuffer->GetSize();        

block_align_size = GetBlockAlignSize();             

average_byte_per_second = GetABPS();          

last_present_time = GetLastPresentTime();           

 

while ( var1< buffer_sample_size)

{

next_present_time = last_present_time  + (var1*1000)/average_byte_per_second;

         if ( (buffer_sample_size - var1) > block_align_size )

         {

                 var1 = var1 + block_align_size;

         }

         else

         {

                   var1 = buffer_sample_size - block_align_size;

         }

         Last_present_time = next_present_time;

}

 

next_present_time = next_present_time + 10;

 

WriteStreamSample (next_present_time,.…);

Adjust DSCP value

Someone asked me how to adjust DSCP value on Windows 2003 server. Of course, you can adjust it in local policy’s network template, but I want to introduce another way.

 

Firstly, you need to install QoS Packet Scheduler services:

QoS Packet

 

 

Secondly, you might want to download Windows 2003 resource kit and install TCMON by double clicking tcmon.bat

 

After you start TCMON.exe, you will find the network interface cards name were listed in the combo box, and the list box should be empty by default. If you see the list is not empty, you might already have flow installed by other applications.

 

You can add a new flow by clicking “add” button, in the parameter tab, just choose “best effort” under service type panel and uncheck other settings. Under advanced parameters tab, check “override DSCP (DCLASS)” and set the value you want. Under Filter tab, you can set different rules to fit your requirement. If you just want to apply the setting to every network traffic packet, please also create a filter with all default settings. Save it and get back to the main window of TCMON, you should be able to find the new flow has been added.

 

Now you can run your network application to send/receive packets, you can use ethereal /network monitor or any other tools to check the DSCP value of every packet.

 

Note, if you close TCMON or restart the machine, the DSCP value will be reset. If you need a tool which can run in background and/or auto start, you might want to write it by yourself. Traffic Control Functions can help you to finish the tool.

 

 

Windows Media Services 9.5 installation

Windows Media Services (WMS) 9.5 RTWed. Now you can grab all installation packages from MSSite. Be sure you’re downloading correct version, if you’re still using Windows 2008 RCx, you also can be able to find related WMS 9.5 RC packages from here.

 

I assume you’ve downloaded and put them in a local folder on your WS08 machine, the installation sequence is: Server.msu, Core.msu and Admin.msu. After you installed these three packages, you should be able to find WMS9.5 shortcut in administrative tools of control panel; but you cannot start it right now, we have something else to be done. I’m not going to introduce WS08 new features, I just tell you about the installation steps of WMS 9.5, but you may find many other system components of WS08 are similar with WMS 9.5 in installation.

 

Open Server Manager from control panel / administrative tools, see figure 1.

addwms95

 

 

It warns you that HTTP protocol is disabled because of port conflicting to IIS7. No worries, you can do what you did in WMS9.1 to fix this.

 

Now, you are able to launch WMS 9.5! You should be very familiar with the WMS Admin MMC UI. The first thing you might want to do is to change the default port of HTTP protocol of WMS 9.5, don’t forget to enable HTTP, it is useful for those silverlight clients. You may notice MMS protocol option has been totally removed from WMS 9.5. That’s true and HTTP should be able to resolve the compatibility issue with Windows Media Player 6.4. MMS prefix still can be used. Protocol rollover will happen if you type and play a MMS address (e.g. mms://server/pp/test.wmv) in WMP, WMP will try to use RTSP firstly, if RTSP attempting fails, it will try HTTP. WMP will negotiate with WMS about protocol rollover, you need to not take care of it yourselves.

 

The most important new feature in WMS9.5 should be a built-in cache/proxy plug-in; you can set it from the cache/proxy property of root node of the server. If you have experience about the old proxy/cache plug-in sample ships with WMS9.1 SDK, you should be able to use the plug-in very quickly.

 

You can learn more about the benefits and new features of WMS9.5 from here.

 

 

Page view tracker