[Live-devel] WebCam as Frame Source
Ioannis Skazikis
iskaz at intracom.gr
Thu Sep 1 09:32:50 PDT 2005
Hallo,
I try to build an RTSP Live Video Stream server based on the live media
library.
I have also read the live Media FAQ + Mailing List and tryed to follow
your answers to questions from the mailing list archive from others
having the same problem like me.
The program is based on the testMPEG4VideoStreammer testprogramm found
in the liveMedia library.
Based on the DeviseSource.cpp I wrote an DeviceSourceCammera subclass of
the FramedSource" which opens a USB Camera, grubs an Image and decodes
it with help of the Revel Lib (XVID encoding Lib) to MPEG4.
The functions which open the device and starts the Server look like this:
void init_play(){
// Open the input source
DeviceParameters params;
fileSource = DeviceSourceCammera::createNew(*env, params);
if (fileSource == NULL) {
*env << "Unable to open source\n";
exit(1);
}
}
void play() {
FramedSource* videoES = fileSource;
// Create a framer for the Video Elementary Stream:
videoSource = MPEG4VideoStreamFramer::createNew(*env, videoES);
// Finally, start playing:
*env << "Beginning to read from file...\n";
videoSink->startPlaying(*videoSource, afterPlaying, videoSink);
}
>From debuging outputs implemented in the DeviceSourceCammera.cpp by
running the programm I can see that it really opens the device, grab a
frame and encodes it (the procedure repeats it self), but if I start the
mplayer, it connects to the servers reads the sdp , it writes as output
at the end "Found video stream: 0" ,but it does not starts to play the
stream. It stays there with out do nothing (like waiting frames, but
never receives them)
Any Idea why (or what?) is happening?
The DeviceSourceCammera.cpp is included in this e-mail.
lvsMain.cpp is the "Main" file with the server start up code (also
included in this e-mail)
DeviceUtil.hh is the Header file which includes the basic Function of my
code for handling the WebCam device. (this works, I have encoded a
video file, before to play with the LiveMedia Lib.)
The subclass Functions look like this. If you need more details please
ask me or have a look in the attached files...
DeviceSourceCammera::DeviceSourceCammera(UsageEnvironment& env,
DeviceParameters params)
: DeviceSource(env, params){
init(); // Open Device
}
void DeviceSourceCammera::doGetNextFrame() {
grab_image(); //Take a Frame from the Camera
if (0 /* the source stops being readable */) {
handleClosure(this);
fprintf(stderr,"In Grab Image V4l, the source stops being readable
!!!!\n");
return;
}
deliverFrame(); // call DeviceSourceCammera::deliverFrame() Function.
}
DeviceSourceCammera::deliverFrame() {
//Encoding the grub frame from the Camera
if (get_grab_size() > fMaxSize){
frameSize = fMaxSize;
}
else frameSize = get_grab_size();
fTo = (unsigned char*)malloc(frameSize);
memcpy(fTo, frame.pixels, frameSize); // frame.pixels is the buffer
where the grubed frame is now encoded, framesize the size of the encoded
frame
}
Thank you very much for your help and your time !!!!
Sorry about my bad english too.
Ioannis.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DeviceSourceCammera.cpp
Type: text/x-c++src
Size: 6173 bytes
Desc: not available
Url : http://lists.live.com/pipermail/live-devel/attachments/20050901/95c419c3/DeviceSourceCammera-0002.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DeviceSourceCammera.hh
Type: text/x-c++hdr
Size: 679 bytes
Desc: not available
Url : http://lists.live.com/pipermail/live-devel/attachments/20050901/95c419c3/DeviceSourceCammera-0003.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DeviceUtil.cpp
Type: text/x-c++src
Size: 3680 bytes
Desc: not available
Url : http://lists.live.com/pipermail/live-devel/attachments/20050901/95c419c3/DeviceUtil-0002.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DeviceUtil.hh
Type: text/x-c++hdr
Size: 501 bytes
Desc: not available
Url : http://lists.live.com/pipermail/live-devel/attachments/20050901/95c419c3/DeviceUtil-0003.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lvsMain.cpp
Type: text/x-c++src
Size: 3670 bytes
Desc: not available
Url : http://lists.live.com/pipermail/live-devel/attachments/20050901/95c419c3/lvsMain-0001.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: revel.h
Type: text/x-chdr
Size: 9981 bytes
Desc: not available
Url : http://lists.live.com/pipermail/live-devel/attachments/20050901/95c419c3/revel-0001.bin
More information about the live-devel
mailing list