Sometimes it is desired to use presentation time already stored with
input frames. For example when data comes already split into frames (but
not NUL units) and if frame rate can't be determined from stream itself
or frames appear with irregular intervals or even skipped entirely.
This patch add option to copy presentation time from input source to
MPEG, H264, H265 stream framers.
---
liveMedia/H264VideoStreamFramer.cpp | 8 ++++----
liveMedia/H264or5VideoStreamDiscreteFramer.cpp | 2 +-
liveMedia/H264or5VideoStreamFramer.cpp | 4 ++--
liveMedia/H265VideoStreamFramer.cpp | 8 ++++----
liveMedia/MPEG1or2VideoStreamFramer.cpp | 10 ++++++----
liveMedia/MPEG4VideoStreamFramer.cpp | 10 ++++++----
liveMedia/MPEGVideoStreamFramer.cpp | 6 +++++-
liveMedia/StreamParser.hh | 2 ++
liveMedia/include/H264VideoStreamFramer.hh | 4 ++--
liveMedia/include/H264or5VideoStreamFramer.hh | 3 ++-
liveMedia/include/H265VideoStreamFramer.hh | 4 ++--
liveMedia/include/MPEG1or2VideoStreamFramer.hh | 8 +++++---
liveMedia/include/MPEG4VideoStreamFramer.hh | 5 +++--
liveMedia/include/MPEGVideoStreamFramer.hh | 3 ++-
14 files changed, 46 insertions(+), 31 deletions(-)
--
Stas Tsymbalov
TrueConf LLC
http://trueconf.com/
diff --git a/liveMedia/H264VideoStreamFramer.cpp b/liveMedia/H264VideoStreamFramer.cpp
index 7eaa4a6..7e06a49 100644
--- a/liveMedia/H264VideoStreamFramer.cpp
+++ b/liveMedia/H264VideoStreamFramer.cpp
@@ -21,13 +21,13 @@ along with this library; if not, write to the Free Software Foundation, Inc.,
#include "H264VideoStreamFramer.hh"
H264VideoStreamFramer* H264VideoStreamFramer
-::createNew(UsageEnvironment& env, FramedSource* inputSource, Boolean includeStartCodeInOutput) {
- return new H264VideoStreamFramer(env, inputSource, True, includeStartCodeInOutput);
+::createNew(UsageEnvironment& env, FramedSource* inputSource, Boolean includeStartCodeInOutput, Boolean useSourcePresentationTime) {
+ return new H264VideoStreamFramer(env, inputSource, True, includeStartCodeInOutput, useSourcePresentationTime);
}
H264VideoStreamFramer
-::H264VideoStreamFramer(UsageEnvironment& env, FramedSource* inputSource, Boolean createParser, Boolean includeStartCodeInOutput)
- : H264or5VideoStreamFramer(264, env, inputSource, createParser, includeStartCodeInOutput) {
+::H264VideoStreamFramer(UsageEnvironment& env, FramedSource* inputSource, Boolean createParser, Boolean includeStartCodeInOutput, Boolean useSourcePresentationTime)
+ : H264or5VideoStreamFramer(264, env, inputSource, createParser, includeStartCodeInOutput, useSourcePresentationTime) {
}
H264VideoStreamFramer::~H264VideoStreamFramer() {
diff --git a/liveMedia/H264or5VideoStreamDiscreteFramer.cpp b/liveMedia/H264or5VideoStreamDiscreteFramer.cpp
index d19288f..1252768 100644
--- a/liveMedia/H264or5VideoStreamDiscreteFramer.cpp
+++ b/liveMedia/H264or5VideoStreamDiscreteFramer.cpp
@@ -25,7 +25,7 @@ along with this library; if not, write to the Free Software Foundation, Inc.,
H264or5VideoStreamDiscreteFramer
::H264or5VideoStreamDiscreteFramer(int hNumber, UsageEnvironment& env, FramedSource* inputSource)
- : H264or5VideoStreamFramer(hNumber, env, inputSource, False/*don't create a parser*/, False) {
+ : H264or5VideoStreamFramer(hNumber, env, inputSource, False/*don't create a parser*/, False, False) {
}
H264or5VideoStreamDiscreteFramer::~H264or5VideoStreamDiscreteFramer() {
diff --git a/liveMedia/H264or5VideoStreamFramer.cpp b/liveMedia/H264or5VideoStreamFramer.cpp
index 5234dcd..249e3e0 100644
--- a/liveMedia/H264or5VideoStreamFramer.cpp
+++ b/liveMedia/H264or5VideoStreamFramer.cpp
@@ -74,8 +74,8 @@ private:
H264or5VideoStreamFramer
::H264or5VideoStreamFramer(int hNumber, UsageEnvironment& env, FramedSource* inputSource,
- Boolean createParser, Boolean includeStartCodeInOutput)
- : MPEGVideoStreamFramer(env, inputSource),
+ Boolean createParser, Boolean includeStartCodeInOutput, Boolean useSourcePresentationTime)
+ : MPEGVideoStreamFramer(env, inputSource, useSourcePresentationTime),
fHNumber(hNumber),
fLastSeenVPS(NULL), fLastSeenVPSSize(0),
fLastSeenSPS(NULL), fLastSeenSPSSize(0),
diff --git a/liveMedia/H265VideoStreamFramer.cpp b/liveMedia/H265VideoStreamFramer.cpp
index 0a61a15..4907565 100644
--- a/liveMedia/H265VideoStreamFramer.cpp
+++ b/liveMedia/H265VideoStreamFramer.cpp
@@ -21,13 +21,13 @@ along with this library; if not, write to the Free Software Foundation, Inc.,
#include "H265VideoStreamFramer.hh"
H265VideoStreamFramer* H265VideoStreamFramer
-::createNew(UsageEnvironment& env, FramedSource* inputSource, Boolean includeStartCodeInOutput) {
- return new H265VideoStreamFramer(env, inputSource, True, includeStartCodeInOutput);
+::createNew(UsageEnvironment& env, FramedSource* inputSource, Boolean includeStartCodeInOutput, Boolean useSourcePresentationTime) {
+ return new H265VideoStreamFramer(env, inputSource, True, includeStartCodeInOutput, useSourcePresentationTime);
}
H265VideoStreamFramer
-::H265VideoStreamFramer(UsageEnvironment& env, FramedSource* inputSource, Boolean createParser, Boolean includeStartCodeInOutput)
- : H264or5VideoStreamFramer(265, env, inputSource, createParser, includeStartCodeInOutput) {
+::H265VideoStreamFramer(UsageEnvironment& env, FramedSource* inputSource, Boolean createParser, Boolean includeStartCodeInOutput, Boolean useSourcePresentationTime)
+ : H264or5VideoStreamFramer(265, env, inputSource, createParser, includeStartCodeInOutput, useSourcePresentationTime) {
}
H265VideoStreamFramer::~H265VideoStreamFramer() {
diff --git a/liveMedia/MPEG1or2VideoStreamFramer.cpp b/liveMedia/MPEG1or2VideoStreamFramer.cpp
index 937dcff..09b96e2 100644
--- a/liveMedia/MPEG1or2VideoStreamFramer.cpp
+++ b/liveMedia/MPEG1or2VideoStreamFramer.cpp
@@ -89,8 +89,9 @@ MPEG1or2VideoStreamFramer::MPEG1or2VideoStreamFramer(UsageEnvironment& env,
FramedSource* inputSource,
Boolean iFramesOnly,
double vshPeriod,
- Boolean createParser)
- : MPEGVideoStreamFramer(env, inputSource) {
+ Boolean createParser,
+ Boolean useSourcePresentationTime)
+ : MPEGVideoStreamFramer(env, inputSource, useSourcePresentationTime) {
fParser = createParser
? new MPEG1or2VideoStreamParser(this, inputSource,
iFramesOnly, vshPeriod)
@@ -104,9 +105,10 @@ MPEG1or2VideoStreamFramer*
MPEG1or2VideoStreamFramer::createNew(UsageEnvironment& env,
FramedSource* inputSource,
Boolean iFramesOnly,
- double vshPeriod) {
+ double vshPeriod,
+ Boolean useSourcePresentationTime) {
// Need to add source type checking here??? #####
- return new MPEG1or2VideoStreamFramer(env, inputSource, iFramesOnly, vshPeriod);
+ return new MPEG1or2VideoStreamFramer(env, inputSource, iFramesOnly, vshPeriod, useSourcePresentationTime);
}
double MPEG1or2VideoStreamFramer::getCurrentPTS() const {
diff --git a/liveMedia/MPEG4VideoStreamFramer.cpp b/liveMedia/MPEG4VideoStreamFramer.cpp
index 7f2a667..6b7f202 100644
--- a/liveMedia/MPEG4VideoStreamFramer.cpp
+++ b/liveMedia/MPEG4VideoStreamFramer.cpp
@@ -89,9 +89,10 @@ private:
MPEG4VideoStreamFramer*
MPEG4VideoStreamFramer::createNew(UsageEnvironment& env,
- FramedSource* inputSource) {
+ FramedSource* inputSource,
+ Boolean useSourcePresentationTime) {
// Need to add source type checking here??? #####
- return new MPEG4VideoStreamFramer(env, inputSource);
+ return new MPEG4VideoStreamFramer(env, inputSource, useSourcePresentationTime);
}
unsigned char* MPEG4VideoStreamFramer
@@ -110,8 +111,9 @@ void MPEG4VideoStreamFramer
MPEG4VideoStreamFramer::MPEG4VideoStreamFramer(UsageEnvironment& env,
FramedSource* inputSource,
- Boolean createParser)
- : MPEGVideoStreamFramer(env, inputSource),
+ Boolean createParser,
+ Boolean useSourcePresentationTime)
+ : MPEGVideoStreamFramer(env, inputSource, useSourcePresentationTime),
fProfileAndLevelIndication(0),
fConfigBytes(NULL), fNumConfigBytes(0),
fNewConfigBytes(NULL), fNumNewConfigBytes(0) {
diff --git a/liveMedia/MPEGVideoStreamFramer.cpp b/liveMedia/MPEGVideoStreamFramer.cpp
index 03e30a4..94b590a 100644
--- a/liveMedia/MPEGVideoStreamFramer.cpp
+++ b/liveMedia/MPEGVideoStreamFramer.cpp
@@ -39,8 +39,10 @@ int TimeCode::operator==(TimeCode const& arg2) {
////////// MPEGVideoStreamFramer implementation //////////
MPEGVideoStreamFramer::MPEGVideoStreamFramer(UsageEnvironment& env,
- FramedSource* inputSource)
+ FramedSource* inputSource,
+ Boolean useSourcePresentationTime)
: FramedFilter(env, inputSource),
+ fUseSourcePresentationTime(useSourcePresentationTime),
fFrameRate(0.0) /* until we learn otherwise */,
fParser(NULL) {
reset();
@@ -159,6 +161,8 @@ void MPEGVideoStreamFramer::continueReadProcessing() {
fNumTruncatedBytes = fParser->numTruncatedBytes();
// "fPresentationTime" should have already been computed.
+ if (fUseSourcePresentationTime)
+ fPresentationTime = fParser->sourcePresentationTime();
// Compute "fDurationInMicroseconds" now:
fDurationInMicroseconds
diff --git a/liveMedia/StreamParser.hh b/liveMedia/StreamParser.hh
index 21db559..32a5593 100644
--- a/liveMedia/StreamParser.hh
+++ b/liveMedia/StreamParser.hh
@@ -29,6 +29,8 @@ class StreamParser {
public:
virtual void flushInput();
+ struct timeval sourcePresentationTime() const { return fLastSeenPresentationTime; }
+
protected: // we're a virtual base class
typedef void (clientContinueFunc)(void* clientData,
unsigned char* ptr, unsigned size,
diff --git a/liveMedia/include/H264VideoStreamFramer.hh b/liveMedia/include/H264VideoStreamFramer.hh
index 3910589..f1ac75c 100644
--- a/liveMedia/include/H264VideoStreamFramer.hh
+++ b/liveMedia/include/H264VideoStreamFramer.hh
@@ -28,11 +28,11 @@ along with this library; if not, write to the Free Software Foundation, Inc.,
class H264VideoStreamFramer: public H264or5VideoStreamFramer {
public:
static H264VideoStreamFramer* createNew(UsageEnvironment& env, FramedSource* inputSource,
- Boolean includeStartCodeInOutput = False);
+ Boolean includeStartCodeInOutput = False, Boolean useSourcePresentationTime = False);
protected:
H264VideoStreamFramer(UsageEnvironment& env, FramedSource* inputSource,
- Boolean createParser, Boolean includeStartCodeInOutput);
+ Boolean createParser, Boolean includeStartCodeInOutput, Boolean useSourcePresentationTime);
// called only by "createNew()"
virtual ~H264VideoStreamFramer();
diff --git a/liveMedia/include/H264or5VideoStreamFramer.hh b/liveMedia/include/H264or5VideoStreamFramer.hh
index 4afe939..707d0ce 100644
--- a/liveMedia/include/H264or5VideoStreamFramer.hh
+++ b/liveMedia/include/H264or5VideoStreamFramer.hh
@@ -51,7 +51,8 @@ public:
protected:
H264or5VideoStreamFramer(int hNumber, // 264 or 265
UsageEnvironment& env, FramedSource* inputSource,
- Boolean createParser, Boolean includeStartCodeInOutput);
+ Boolean createParser, Boolean includeStartCodeInOutput,
+ Boolean useSourcePresentationTime);
// We're an abstract base class.
virtual ~H264or5VideoStreamFramer();
diff --git a/liveMedia/include/H265VideoStreamFramer.hh b/liveMedia/include/H265VideoStreamFramer.hh
index e63ac58..a589f31 100644
--- a/liveMedia/include/H265VideoStreamFramer.hh
+++ b/liveMedia/include/H265VideoStreamFramer.hh
@@ -28,10 +28,10 @@ along with this library; if not, write to the Free Software Foundation, Inc.,
class H265VideoStreamFramer: public H264or5VideoStreamFramer {
public:
static H265VideoStreamFramer* createNew(UsageEnvironment& env, FramedSource* inputSource,
- Boolean includeStartCodeInOutput = False);
+ Boolean includeStartCodeInOutput = False, Boolean useSourcePresentationTime = False);
protected:
- H265VideoStreamFramer(UsageEnvironment& env, FramedSource* inputSource, Boolean createParser, Boolean includeStartCodeInOutput);
+ H265VideoStreamFramer(UsageEnvironment& env, FramedSource* inputSource, Boolean createParser, Boolean includeStartCodeInOutput, Boolean useSourcePresentationTime);
// called only by "createNew()"
virtual ~H265VideoStreamFramer();
diff --git a/liveMedia/include/MPEG1or2VideoStreamFramer.hh b/liveMedia/include/MPEG1or2VideoStreamFramer.hh
index 5f2f126..f9c248a 100644
--- a/liveMedia/include/MPEG1or2VideoStreamFramer.hh
+++ b/liveMedia/include/MPEG1or2VideoStreamFramer.hh
@@ -31,15 +31,17 @@ public:
static MPEG1or2VideoStreamFramer*
createNew(UsageEnvironment& env, FramedSource* inputSource,
Boolean iFramesOnly = False,
- double vshPeriod = 5.0
+ double vshPeriod = 5.0,
/* how often (in seconds) to inject a Video_Sequence_Header,
- if one doesn't already appear in the stream */);
+ if one doesn't already appear in the stream */
+ Boolean useSourcePresentationTime = False);
protected:
MPEG1or2VideoStreamFramer(UsageEnvironment& env,
FramedSource* inputSource,
Boolean iFramesOnly, double vshPeriod,
- Boolean createParser = True);
+ Boolean createParser = True,
+ Boolean useSourcePresentationTime = False);
// called only by createNew(), or by subclass constructors
virtual ~MPEG1or2VideoStreamFramer();
diff --git a/liveMedia/include/MPEG4VideoStreamFramer.hh b/liveMedia/include/MPEG4VideoStreamFramer.hh
index 9efdfd7..0a74d1d 100644
--- a/liveMedia/include/MPEG4VideoStreamFramer.hh
+++ b/liveMedia/include/MPEG4VideoStreamFramer.hh
@@ -33,7 +33,7 @@ along with this library; if not, write to the Free Software Foundation, Inc.,
class MPEG4VideoStreamFramer: public MPEGVideoStreamFramer {
public:
static MPEG4VideoStreamFramer*
- createNew(UsageEnvironment& env, FramedSource* inputSource);
+ createNew(UsageEnvironment& env, FramedSource* inputSource, Boolean useSourcePresentationTime = False);
u_int8_t profile_and_level_indication() const {
return fProfileAndLevelIndication;
@@ -48,7 +48,8 @@ public:
protected:
MPEG4VideoStreamFramer(UsageEnvironment& env,
FramedSource* inputSource,
- Boolean createParser = True);
+ Boolean createParser = True,
+ Boolean useSourcePresentationTime = False);
// called only by createNew(), or by subclass constructors
virtual ~MPEG4VideoStreamFramer();
diff --git a/liveMedia/include/MPEGVideoStreamFramer.hh b/liveMedia/include/MPEGVideoStreamFramer.hh
index c6eb87e..3ee56ed 100644
--- a/liveMedia/include/MPEGVideoStreamFramer.hh
+++ b/liveMedia/include/MPEGVideoStreamFramer.hh
@@ -43,7 +43,7 @@ public:
void flushInput(); // called if there is a discontinuity (seeking) in the input
protected:
- MPEGVideoStreamFramer(UsageEnvironment& env, FramedSource* inputSource);
+ MPEGVideoStreamFramer(UsageEnvironment& env, FramedSource* inputSource, Boolean useSourcePresentationTime);
// we're an abstract base class
virtual ~MPEGVideoStreamFramer();
@@ -64,6 +64,7 @@ private:
void continueReadProcessing();
protected:
+ Boolean fUseSourcePresentationTime;
double fFrameRate; // Note: For MPEG-4, this is really a 'tick rate'
unsigned fPictureCount; // hack used to implement doGetNextFrame()
Boolean fPictureEndMarker;
_______________________________________________
live-devel mailing list
[email protected]
http://lists.live555.com/mailman/listinfo/live-devel