[Live-devel] Proper use of StreamReplicator
Ross Finlayson
finlayson at live555.com
Fri Oct 17 11:48:40 PDT 2014
> Ok, I think I've found the issue. The culprit here is the StreamReplica class which is
> a FrameSource, but it is not a JPEG video source, i.e. it does not return True for:
>
> virtual Boolean isJPEGVideoSource();
OK, so yes - that’s the problem.
The data that you feed to “JPEGVideoRTPSink” MUST BE a subclass of “JPEGVideoSource”. It can’t just redefine “isJPEGVideoSource()” to return True (or just do some type casting hack). The reason for this is that “JPEGVideoRTPSink” needs to know the “type”, “qFactor”, “width”, and “height” of the frames that it receives (so it can pack these values into the appropriate fields of the outgoing RTP packet).
So, you’ll need to define your own subclass of “JPEGVideoSource” - e.g., called “ReplicaJPEGVideoSource”. This must take as input another “FramedSource” object (a “StreamReplica”, in your case), and must implement the following (pure) virtual functions: “doGetNextFrame()”, “type()”, “qFactor()”, “width()”, “height()”.
Implementing “doGetNextFrame()” is easy; just call “getNextFrame()” on the input (“StreamReplica”) object.
To implement the other virtual functions (“type()”, “qFactor()”, “width()”, “height()”), you’ll need to have these four parameters added to each frame of data somehow. I.e., you’ll need to modify your original JPEG video source object - i.e., the one that you feed into the “StreamReplicator” - to add a header at the start (or at the end) that contains these four values.
These four values will presumably also be useful to the other replica - the one that you feed into a “FileSink”.
Your “ReplicaJPEGVideoSource” class should also make sure that its destructor calls “Medium::close()” on the input source (a “StreamReplica”), and should also reimplement the “doStopGettingFrames()” virtual function to call “stopGettingFrames()” on the input source. (Note the implementation of “FramedFilter”, which does the same thing. In fact, you *might* try having your “ReplicaJPEGVideoSource” class inherit from both “JPEGVideoSource” and “FramedFilter”, but I’m not sure whether or not that will work. (I’m wary of multiple inheritance in C++, and haven’t used it at all in any of the LIVE555 code so far.))
Finally, you’ll need to modify your implementation of “createNewStreamSource()” to not just return a new “StreamReplica”, but instead to feed this “StreamReplica” into a new “ReplicaJPEGVideoSource” object, and then return a pointer to this new “ReplicaJPEGVideoSource” object.
Ross Finlayson
Live Networks, Inc.
http://www.live555.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20141017/1bd80490/attachment.html>
More information about the live-devel
mailing list