why dont you use windows media player?
Main Topics
Browse All TopicsHello,
I am a developer working on an application that will run on the Windows CE 5.0 Core platform. The application requires video playback, and I am having trouble finding an acceptable way to implement this. I have a lot of flexibility over the file format of the video files that will be played. I don't necessarily need to support multiple formats... if I can get even one format working then that should be sufficient. MPG, WMV, AVI, or MOV would all work and if I can support more than one of them (which I know that DirectShow is capable of) then that will be a great advantage. The video files will all be stored on local storage, so I do not need to be able to support network streaming at this point, though leaving open the possibility of adding that functionality in the future would be a huge plus.
The target device will be running a Samsung ARM 400 MHz processor, so it seems to me that the solution will have to include some library that can take advantage of hardware rendering. Initial tests with software-only rendering have provided little hope that that type of solution could be acceptable with our limited processor speed.
The Windows CE 5.0 OS Image that we will be using does NOT include the Windows Media Player or associated OCX, so that is not a possibility. Right now I am leaning towards using the DirectShow library, which definitely WILL be available on my target device. But I am not locked into DirectShow if I can find a better solution. I am also considering licensing the third-party TCPMP player from CoreCodec, but our requirements seem so simple, theoretically, that I would prefer to avoid incurring additional third-party licensing and support costs if at all possible. Especially in light of the fact that DirectShow is available for no extra cost as part of our OS platform.
I have a device in my possession, for performance testing, that has the same chip that our final target device has, but I do not have access to our final target hardware at this point in time. The device that I do have is running Windows Mobile 5.0. This is NOT our target OS, as I mentioned above... but Windows Mobile does claim to support DirectShow, so I assume that if I can get a DirectShow video player application to compile on run on the WinMobile 5.0 device, the application should run OK on the real target device when I get my hands on it. I am aware that I need to avoid using any WinMobile5.0 features that may not be available in our target OS of WinCE 5.0 Core.
Developing an application for the Windows Mobile 5.0 platform requires Visual Studio 2005, so that seems like a requirement at this point. Also, I expect VS2005 to be much more useful in the future for new devices that we may want to support than if we developed the application using embedded VC++ or some combination of that and Visual Studio.NET 2003.
At this point, I am simply trying to get a simple DirectShow video playback application to compile in VS2005 and deploy and run it on the Windows Mobile 5.0 emulator or on my physical WM5.0 device. I am using a Visual C++ Smart Device Win32 Application project in VS2005, and have virtually copied and pasted my code from the DirectShow for WinCE 5.0 sample code available on MSDN here:
http://msdn.microsoft.com/
I can not get it to compile. It is not a link error, it is a compile error that has to do with these two lines of code:
#define WM_GRAPHNOTIFY WM_APP + 1
and
pEvent->SetNotifyWindow((O
The compile error is about syntax. It says this:
syntax error : missing ')' before ';'
I can give more specific details about the compile error if that would be useful, but I strongly suspect that it has to do with the definition of "WM_APP" being incompatible with its use in this fashion. I'm assuming this is to do some change to that definition that occurred between VS2003 and VS2005. Microsoft's sample code page doesn't seem to state it specifically, but I suspect that it was written and tested under VS2003 and not VS2005.
So the ideal answer to this question and a solution that I would gladly award 500 points for would be if someone can give me a working example of how to modify Microsoft's sample code (from the link above) to compile in VS2005 and successfully deploy to the WM5.0 emulator (optional) and my physical WM5.0 device (required).
However if anyone has any other suggestions or comments about my approach or an alternative than seems more desirable or has a higher probability of success, I will divy up so points for any useful information about that as well.
One other factor: there will be an ActiveX component involved in the application as well, for the User Interface. I know that without third-party software, this will have to be accomplished via C++ as well. However, besides the video playback and the ActiveX control, I am hoping to implement as much of the rest of the application logic as possible in C#. So after I get a working standalone VS2005 C++ app playing video via DirectShow (which is my immediate goal so I can test performance on the hardware), I am hoping to create a new project that is a wrapper DLL rather than an actual application, and to have the ability to access that and any other C++ code from through the wrapper DLLs from the main C# application. This is not an absolute requirement but would be a HUGE benefit unless it might cause performance issues.
All feedback is welcome! Thanks in advance!
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
mahesh1402: thank you for your comment. However the compile error is coming from this line:
pEvent->SetNotifyWindow((O
the specific compile error is:
syntax error: missing ')' before ';'
if you look at the line that is causing the compile error, you will notice that syntactically it looks perfectly correct. The parentheses are matched up. This implies to me that whatever the compiler is replacing WM_GRAPHNOTIFY with (due to the #define line), is causing the syntax error. The define line is:
#define WM_GRAPHNOTIFY WM_APP + 1
I have no idea what the previous definition for "WM_APP" might be, but I'm assuming that it most include some kind of special character like a semicolon. That's the only thing I can think of that would cause the syntax error at compile time--because the line looks perfectly syntactically correct to me.
Mikal613: Thank you for your comment, however, as I stated in my original post:
"The Windows CE 5.0 OS Image that we will be using does NOT include the Windows Media Player or associated OCX, so that is not a possibility. Right now I am leaning towards using the DirectShow library, which definitely WILL be available on my target device. But I am not locked into DirectShow if I can find a better solution. I am also considering licensing the third-party TCPMP player from CoreCodec, but our requirements seem so simple, theoretically, that I would prefer to avoid incurring additional third-party licensing and support costs if at all possible. Especially in light of the fact that DirectShow is available for no extra cost as part of our OS platform."
I understand that WMP is included in the WinMobile 5.0 platform that I am using for testing, but that does me no good because it won't be available on my final target platform.
is the line before the pEvent correct?
if it is then i don't see how it wont work, as puzzled as you, as you said, the syntax is perfectly correct.
BTW, WM_APP is defined as 0x8000, so there is no error there.
It is most likely that something in the code before this is stuffed up and the compiler only picked up the error now.
what you can try, is repleace the code with
pEvent->SetNotifyWindow(Nu
does that stil give you syntax error? if so then maybe the lines before it are really messed up
Also, doesnt the SetNotifyWindow thing belong to <dshow.h>? *I'm not sure about the CE5 header*
TCPMP *used* to be an open source project, and technically I think they are still willing to provide source under certain circumstances, but they no longer make the source available in their download package. I am under the impression that they are in the process of changing their licensing model. I have sent them e-mail to try to get an idea of what their plans are for the licensing model, and what requirements they now have for acquiring the source, but I haven't heard back from them yet. I expect that those folks are pretty darn busy and am not expecting them to be very responsive in getting back to me, which is one of the reasons I'm leaning towards rolling my own player instead of trying to integrate theirs. It's a shame because I am confident that my company would be willing to pay them for some commercial support but it just doesn't seem likely that they are going to have the time or interest in that.
Thank you for the code suggestions, and especially for the info about the definition of WM_APP. Your suggestions make a lot of sense, and those are some good clues as to how I can try to figure out what's wrong. I will try them out and post any further info that I can glean.
sakuya_su, you are my hero :)
thanks to your help I solved a big part of my problem. i am giving you at least 250 points of the 500 for this question.
unfortunately i am still having a problem, so i would like to ask a further question or two and see if you or anyone else can help before i "accept" a final answer.
The problem is, WM_APP was never being defined. I thought that was supposed to happen from including <windows.h>, but apparently either I am wrong about that or it is different for WinCE/WinMobile than it is for other Win32 OS's.
so, for the time being, I changed:
#define WM_GRAPHNOTIFY WM_APP + 1
to
#define WM_GRAPHNOTIFY (0x8000 + 1)
and now my app compiles and deploys to the WinMobile5.0 emulator successfully. Unfortunately, the program crashes on this line:
pGraph->RenderFile(L"\\mym
I get an exception window that reads:
Unhandled exception at 0x00011198 in DirectShowWM5_cpp_Win32.ex
0xC0000005: Access violation reading location 0x00000000.
Forgive me if this is a stupid question but it's been a while since I've written C++ code, and I've *NEVER* written DirectShow code. To me, the 0x00000000 instantly implies that I'm somehow trying to do something to a pointer that is set to NULL. But I copied and pasted this code straight from Microsoft's sample code so I don't know how I could have screwed anything up. I will be happy to paste my full source if it would be useful but it is pretty much EXACTLY the same as the sample code at the Microsoft URL in my first post in this thread.
The only thing that I could think of was that maybe the filepath that I was specifying was invalid, or that the DirectShow libraries installed on the emulator don't support the video format of my file. So I've tried moving the file to different folders and adjusting my string accordingly, and I've tried several different file formats: AVI, MPG, WMV. I can successfully play the WMV file in the Windows Media Player that is installed in the emulator--but none of the other formats will play in WMP.
The fact that the WMV file will play in WMP implies in my mind that the required codecs for WMV are alive and well on the emulator... so I would think that the DirectShow code should be able to AT LEAST play a WMV file. But I get the same exception with the "Access Violation 0x00000000" even with the WMV file. I have the WMV file stored in the root directory of the emulator's filesystem so I don't see how I could possibly have the path string wrong in my code.
So here are my two questions for now:
1) Anybody know what file(s) i need to #include to get WM_APP defined? I will poke through the .h files in the SDK and see if I can answer that question myself but any suggestions would be great.
2) Anyone familiar enough with DirectShow to have any idea why I am getting this "Accesss Violation 0x00000000" exception? Where am I screwing up and leaving a pointer NULL?
sakuya_su, again, thanks so much for your help, i'm a lot closer now than i was before!!
apparently, if you use an Pocket PC you'll notice that there are only 3 format WMP can play on a PPC:
- WMV... duh, its MS
- Avi with either:
1. Microsoft MPEG-4 V1 Encoder
2. or the MS MPEG-4 V2 Encoder
if the code you called upon can actually play WMV< then the code is working? try converting ur Avi to a MPEG-4 Version2 avi file(its actually a WMV file but you can rename it to avi XD).
to do that, you can use the Windows Media Encoder (free)
as for the WM_APP...
http://msdn.microsoft.com/
it says its declared in winuser.h and includede in windows.h... but what the heck, if it dont work you can just define your own.
good luck
Thanks for the info about WM_APP. I'm not too concerned about that issue because I will either find the right header file, or just define it myself like you suggested.
My program still doesn't work though. I tried a WMV file--that was the first format I tried since I assumed it was the most likely to work with Microsoft libraries. It plays fine in the actual Windows Media Player application that was pre-installed on the PocketPC emulator. But when I try to play it from my DirectShow program, my program still crashes on this line:
pGraph->RenderFile(L"\\mym
It still gives me the same exception:
Unhandled exception at 0x00011198 in DirectShowWM5_cpp_Win32.ex
0xC0000005: Access violation reading location 0x00000000.
The null pointer thing makes me think that there's something else wrong besides the file format--but I'm not sure...
yeah
RenderFile is:
pGraph->RenderFile(Path, NULL);
now, the problem with yours is... "\\myhomemovie.wmv" is not a valid path name.. as \\means a network path
try..
hr = pGraph->RenderFile(L"C:\\M
look at this:
http://msdn.microsoft.com/
Thanks for spending so much of your time with me on this.
Two points in response to your last comment.
Point #1: On a WinCE device, there is no "C:". All file paths just start with "\\". See the following URL's, which are basically just WinCE specific versions of the same docs you were looking at.
http://msdn.microsoft.com/
Note the comment: "// Filenames on Windows CE start with a \\ instead of a drive letter."
and you can see it in their full code sample here.
http://msdn.microsoft.com/
Point #2: In the link that you just sent me, there are a ton of error codes that imply that if my file path or video file format was invalid, I would get an HRESULT return value with the appropriate error code for me to check against. But I am never getting a return value at all--it is crashing with an exception before it ever has a chance to return anything.
I am trying a local file. I don't even need the ability to support network files in my application. The WMV file is stored in the root directory of the WinCE device.
L"\\MyMovie.wmv" IS the windows CE equivalent of
L"C:\\MyMovie.wmv" on XP or other Win32.
Look at the comments in the code snippet at this URL:
http://msdn.microsoft.com/
IGraphBuilder *pGraph;
IMediaControl *pMediaControl;
CoCreateInstance(CLSID_Fil
IID_IGraphBuilder, (void **)&pGraph);
// Query for IMediaControl (not shown)
// Filenames on Windows CE start with a \\ instead of a drive letter.
pGraph->RenderFile(L"\\Hel
pMediaControl->Run();
The part I'm trying to draw your attention to is "Filenames on Windows CE start with a \\ instead of a drive letter."
please don't apologize, i greatly appreciate you spending so much of your time looking into it.
I have tried putting the file on the SD card, I've tried putting it in the "My Documents" folder, I've tried putting it in the "Temp" folder, and about 5 other places (always changing the PATH string in my RenderFile line accordingly, of course), and none of it has worked.
From the last url that you posted for me:
http://msdn.microsoft.com/
look at the list of return values (HRESULT codes). Notice that there are error codes listed for "NOT_FOUND", "UNKNOWN_FILE_TYPE", "INVALID_FILE_FORMAT", "INVALIDARG", "ABORT", "FAIL", etc.
so if the problem was that I got the path wrong, then I should just get back one of those error codes as a return value, instead of the program crashing with an unhandled exception. So I don't think the file path is the problem.
If you want to see the exception yourself I will be happy to give you my source file, or you can copy and paste the code straight off of the Microsoft page. The Windows Mobile 5.0 emulator is free, it comes with the Windows Mobile 5.0 SDK... but only works with Visual Studio 2005...
thank you..
Hello cprice404
What Mahesh1402 is saying is correct. Becaus as you say
**************************
so, for the time being, I changed:
#define WM_GRAPHNOTIFY WM_APP + 1
to
#define WM_GRAPHNOTIFY (0x8000 + 1)
and now my app compiles and deploys to the WinMobile5.0 emulator successfully. Unfortunately, the program crashes on this line:
**************************
Then the chances are that you havent defined the WM_APP is not defined at the time when the preprocessing is happening. so whats happening is WM_APP is not getting replaced with any value.
So go back and check the includes of WM_APP. Those shold be before the Microsoft Includes.
I guess you have used the code from
http://msdn.microsoft.com/
Then you need to check the above.
Good Luck
umahesh
About the include file for WM_APP
It is declared in Winuser.h, include Windows.h
http://msdn.microsoft.com/
Good Luck,
umahesh
Thanks everyone, I think this is the right track here. I think there is some stuff that is supposed to get defined when WM_APP is supposed to get defined that isn't, and that's probably why I'm crashing.
As for mahesh1402 and umahesh's comments about making sure the directx paths are before the microsoft include paths--I am not using anything from DirectX except for DirectShow, and with Visual Studio 2005 and WinMobile5.0 SDK, the DirectShow stuff is included in the WinMobile 5.0 SDK, so I never even had to install the DirectX SDK. So all of my includes/libs for both Windows and DirectShow are coming from the same paths, which on my install happen to be:
includes: C:\Program Files\Windows CE Tools\wce500\Windows Mobile 5.0 Pocket PC SDK\Include\Armv4i
libs: C:\Program Filews\Windows CE Tools\wce500\Windows Mobile 5.0 Pocket PC SDK\lib\ARMV4I
Furthermore, I have checked and double checked my include paths, and I am positive that the first <windows.h> that it is finding is from the directory I mentioned above. Looking through the windows.h file, I do see a line that says #include <winuser.h>. Double checking the paths again, I am certain that the first "winuser.h" it would find is also in that same includes directory.
Inside <winuser.h> I see the line that is supposed to define WM_APP, but it is obviously never being reached, because my program won't compile if I try to make any reference to WM_APP. Obviously there is an "ifdef" or "ifndef" somewhere that is preventing the compiler from reaching the "<winuser.h>" file, or inside of that file it's not reaching the "#define WM_APP" line. I have looked at all of the "ifdef" and "ifndef" lines that encompass those, and I don't see any obvious reason why any of them would fail.
the includes in my .cpp file are in this order:
#include "stdafx.h" // autogenerated by VS2005
#include "MyApp.h" // autogenerated by VS2005
#include <windows.h> // added by me because it is in the Microsoft WinCE DirectShow sample code
#include <streams.h> // added my be because this is where the DirectShow definitions are
if anyone can give me any clues on how to figure out why winuser.h or WM_APP is not getting processed at compile time that would be very helpful...
I will try to do a Win32 version and see if anything different happens... unfortunately I have to install the Windows Platform SDK to get the DirectShow stuff for Win32, and I have found some posts on newsgroups and such that suggest that the latest Platform SDK DirectShow stuff doesn't work very well with VS2005.
thanks all for your help
ok i have some new info. I started trying to do a Win32 version of this to see if that would give me any clues.
First of all, WM_APP gets set properly in the Win32 version, even though my include lines are exactly the same. But the Win32 App still crashes on the same line. So I'm almost positive that the WM_APP definition is not the problem--though I still don't know why WM_APP isn't getting defined in the WinCE version.
Playing around with the debugger on the Win32 version, I found a major clue. The line that is crashing is this one:
pGraph->RenderFile(L"C:\\M
The exception is a NULL pointer exception. It finally occurred to me to check and see if "pGraph" was set to NULL for some reason... and bingo, it sure is.
So the next question is, why is pGraph set to NULL? It is supposed to get initialized on the line directly preceding that, which is:
CoCreateInstance(CLSID_Fil
IID_IGraphBuilder, (void **)&pGraph);
For some reason that line is leaving pGraph set to NULL. I will read up on the docs of CoCreateInstance and see if I can get a return value with an error code or something, but I thought I'd go ahead and post this info in case it means something meaningful to any of you.
Changed the CoCreateInstance line to:
HRESULT result = CoCreateInstance(CLSID_Fil
IID_IGraphBuilder, (void **)&pGraph);
the value of "result" gets set to:
0x800401f0 CoInitialize has not been called.
This sounds like Microsoft just left a few COM-related setup lines out of their sample code, and I have too little experience with COM to have known that they needed to be there. I will keep poking through the docs, I think I should be able to figure it out now, but if anyone already knows what I'm missing, let me know.
Adding one line:
CoInitialize(NULL);
above the CoCreateInstance line fixes everything on the Win32 version. The video plays successfully.
I went back into the WinCE version and made the same fix. The program no longer crashes, it runs now... but it doesn't actually play the video. Still looking through docs... any thoughts appreciated...
I have narrowed down the problem a little bit more. I am now saving the HRESULT return value from the RenderFile command. The value that it is set to after it fails to play the video is VFW_E_CANNOT_RENDER, which as I understand means that it can't find an appropriate filter/codec for this file format. But the file in question is a WMV file. If DirectShow can play ANYTHING it should be able to play WMV, shouldn't it? I can play this same WMV file just fine in the Windows Media Player application on the emulator. And Windows Media Player is built on DirectShow so why would I get this "CANNOT_RENDER" error?
I also tried changing the file path argument to RenderFile to an invalid path, intentionally, to see if I got the same error. When I use an invalid file path, I get VFW_E_NOT_FOUND as my error code. So I know that I have my file path correct when I am getting the CANNOT_RENDER error code--I just don't know why I am getting that error code.
Any clues?
Hello
I am starting from your first problem
1) First about the exception which occurs at
pGraph->RenderFile(L"\\mym
Unhandled exception at 0x00011198 in DirectShowWM5_cpp_Win32.ex
0xC0000005: Access violation reading location 0x00000000.
This error message is a bit cryptic, but it's understandable if broken down. 0xC0000005 is the error code designation for an Access Violation. 0x00000000 is the location that we tried to read (this is our NULL value!). And, 0x00011198 is the arbitrary memory location where our application happened to be running at the time of the crash (in platform builder you can trace this location and find which module is running there).
For Win32 processes - OS protect lowest 4Mb (hmm, is it realy 4Mb or 4Kb only ?) of memory space from reading/writing.
See http://support.microsoft.c
Thus - while trying to read anything from this area (including from address 0) in user-mode Win32 process you will get page fault that will be translated to exception with code EXCEPTION_ACCESS_VIOLATION
But in DOS - this will be completely legal code and you will get some information from interrupt vector table (becouse IVT reside at this addresses)
BTW, Even in Win32 - this is legal code. You can plug some exception handler for AV exception and perform some magic based on address accessed. For example you can see how you can allocate memory dynamicaly as result of exceptions at http://msdn.microsoft.com/
2) I have seen some times that,
calling a virtual function that doesn not exists for an object, or the linker got screwed up and linked to an invalid fonction pointer), or calling an object that has been deleted already, possibly to do with objects being statically created or an invalid reference to an object that's not present anymore
The other option could be
derefrencing error in a destructor. Put breakpoints on your destructors and step through them all on exit to see where you get the fault.
So check your in
void CleanUp(void)
and set all pointers to NULL after deletion and before new | at constructors
3) Now you are at a point where you are able to run your code but its not getting rendered,
Please see the suppoprted codec types by DirectX under WinCE
Again while playing a file the filter graph need to be completed. The avi or wmv file is splitted in to video and audio. The video part is again given to specific codec and then it goes to renderer. If you are playing it in own filter wrapper code then you need to check the filter graph. The pin allocation must match the output pin of previous filter to the input pin of the next filter and so on. If it fails then you will get error related to codec filter.
If you are getting blank screen only then there is WinCE update for that error see here..
just copy and paste following link in IE and download those updates for directX for your Win CE version.
http://www.microsoft.com/d
Good luck
Umahesh
Here is details about the video codec and renders supported in Windows CE5.0
http://msdn.microsoft.com/
Good luck
Business Accounts
Answer for Membership
by: mahesh1402Posted on 2006-01-12 at 03:41:59ID: 15680216
Make sure you DirectX Include/Lib path are BEFORE the Microsoft Includes.