[Live-devel] Proper use of StreamReplicator

Jan Ekholm jan.ekholm at d-pointer.com
Fri Oct 17 02:16:38 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();

This is what is checked in:

Boolean JPEGVideoRTPSink::sourceIsCompatibleWithUs(MediaSource& source) {
 return source.isJPEGVideoSource();
}

which is checked from:

Boolean MediaSink::startPlaying(MediaSource& source,
				afterPlayingFunc* afterFunc,
				void* afterClientData) {
// Make sure we're not already being played:
 if (fSource != NULL) {
   envir().setResultMsg("This sink is already being played");
   return False;
 }

// HERE 
 // Make sure our source is compatible:
 if (!sourceIsCompatibleWithUs(source)) {
  envir().setResultMsg("MediaSink::startPlaying(): source is not compatible!");
   return False;
 }
...

To me it seems as if StreamReplica should forward all the methods below to the replicated source?

 // Test for specific types of source:
 virtual Boolean isFramedSource() const;
 virtual Boolean isRTPSource() const;
 virtual Boolean isMPEG1or2VideoStreamFramer() const;
 virtual Boolean isMPEG4VideoStreamFramer() const;
 virtual Boolean isH264VideoStreamFramer() const;
 virtual Boolean isH265VideoStreamFramer() const;
 virtual Boolean isDVVideoStreamFramer() const;
 virtual Boolean isJPEGVideoSource() const;
 virtual Boolean isAMRAudioSource() const;

But if I redefine that methods it all crashes later in:

unsigned JPEGVideoRTPSink::specialHeaderSize() const {
 // Our source is known to be a JPEGVideoSource
 JPEGVideoSource* source = (JPEGVideoSource*)fSource;
 if (source == NULL) return 0; // sanity check
...

Here the source is a StreamReplicator and not a JPEGVideoSource, so the cast will be bogus.
Would perhaps be better to use dynamic_cast<> here, then the sanity check would work. As the
StreamReplica class is internal to StreamReplicator specialHeaderSize() can not check for it when
casting and do special handling for that case.

So, for MJPEG there are a few issues.

-- 
Jan Ekholm
jan.ekholm at d-pointer.com






More information about the live-devel mailing list