-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add audio to all stream (thanks to @PieVo)
- Loading branch information
1 parent
14c0209
commit 5a2048f
Showing
15 changed files
with
239 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include "liveMedia.hh" | ||
#include "BasicUsageEnvironment.hh" | ||
|
||
class DummySink: public MediaSink { | ||
public: | ||
static DummySink* createNew(UsageEnvironment& env, | ||
char const* streamId = NULL); // identifies the stream itself (optional) | ||
|
||
private: | ||
DummySink(UsageEnvironment& env, char const* streamId); | ||
// called only by "createNew()" | ||
virtual ~DummySink(); | ||
|
||
static void afterGettingFrame(void* clientData, unsigned frameSize, | ||
unsigned numTruncatedBytes, | ||
struct timeval presentationTime, | ||
unsigned durationInMicroseconds); | ||
void afterGettingFrame(unsigned frameSize, unsigned numTruncatedBytes, | ||
struct timeval presentationTime, unsigned durationInMicroseconds); | ||
|
||
private: | ||
// redefined virtual functions: | ||
virtual Boolean continuePlaying(); | ||
|
||
private: | ||
u_int8_t* fReceiveBuffer; | ||
char* fStreamId; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#include "liveMedia.hh" | ||
#include "BasicUsageEnvironment.hh" | ||
#include "DummySink.hh" | ||
|
||
// Implementation of "DummySink": | ||
|
||
// Even though we're not going to be doing anything with the incoming data, we still need to receive it. | ||
// Define the size of the buffer that we'll use: | ||
#define DUMMY_SINK_RECEIVE_BUFFER_SIZE 100000 | ||
|
||
DummySink* DummySink::createNew(UsageEnvironment& env, char const* streamId) { | ||
return new DummySink(env, streamId); | ||
} | ||
|
||
DummySink::DummySink(UsageEnvironment& env, char const* streamId) | ||
: MediaSink(env) { | ||
fStreamId = strDup(streamId); | ||
fReceiveBuffer = new u_int8_t[DUMMY_SINK_RECEIVE_BUFFER_SIZE]; | ||
} | ||
|
||
DummySink::~DummySink() { | ||
delete[] fReceiveBuffer; | ||
delete[] fStreamId; | ||
} | ||
|
||
void DummySink::afterGettingFrame(void* clientData, unsigned frameSize, unsigned numTruncatedBytes, | ||
struct timeval presentationTime, unsigned durationInMicroseconds) { | ||
DummySink* sink = (DummySink*)clientData; | ||
sink->afterGettingFrame(frameSize, numTruncatedBytes, presentationTime, durationInMicroseconds); | ||
} | ||
|
||
// If you don't want to see debugging output for each received frame, then comment out the following line: | ||
#define DEBUG_PRINT_EACH_RECEIVED_FRAME 1 | ||
|
||
void DummySink::afterGettingFrame(unsigned frameSize, unsigned numTruncatedBytes, | ||
struct timeval presentationTime, unsigned /*durationInMicroseconds*/) { | ||
// We've just received a frame of data. (Optionally) print out information about it: | ||
#ifdef DEBUG | ||
if ((int)presentationTime.tv_sec % 10 == 0) { | ||
char uSecsStr[6+1]; // used to output the 'microseconds' part of the presentation time | ||
sprintf(uSecsStr, "%06u", (unsigned)presentationTime.tv_usec); | ||
envir() << "DummySink Presentation time: " << (int)presentationTime.tv_sec << "." << uSecsStr; | ||
} | ||
#endif | ||
|
||
// Then continue, to request the next frame of data: | ||
continuePlaying(); | ||
} | ||
|
||
Boolean DummySink::continuePlaying() { | ||
if (fSource == NULL) return False; // sanity check (should not happen) | ||
|
||
// Request the next frame of data from our input source. "afterGettingFrame()" will get called later, when it arrives: | ||
fSource->getNextFrame(fReceiveBuffer, DUMMY_SINK_RECEIVE_BUFFER_SIZE, | ||
afterGettingFrame, this, | ||
onSourceClosure, this); | ||
return True; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.