|
@@ -364,17 +364,17 @@ shared_ptr<Stream> createStream(const string h264Samples, const unsigned fps, co
|
|
|
for (auto clientTrack: tracks) {
|
|
|
auto client = clientTrack.id;
|
|
|
auto trackData = clientTrack.trackData;
|
|
|
+ auto rtpConfig = trackData->sender->rtpConfig;
|
|
|
+
|
|
|
// sample time is in us, we need to convert it to seconds
|
|
|
auto elapsedSeconds = double(sampleTime) / (1000 * 1000);
|
|
|
- auto rtpConfig = trackData->sender->rtpConfig;
|
|
|
// get elapsed time in clock rate
|
|
|
uint32_t elapsedTimestamp = rtpConfig->secondsToTimestamp(elapsedSeconds);
|
|
|
-
|
|
|
// set new timestamp
|
|
|
rtpConfig->timestamp = rtpConfig->startTimestamp + elapsedTimestamp;
|
|
|
|
|
|
// get elapsed time in clock rate from last RTCP sender report
|
|
|
- auto reportElapsedTimestamp = rtpConfig->timestamp - trackData->sender->previousReportedTimestamp;
|
|
|
+ auto reportElapsedTimestamp = rtpConfig->timestamp - trackData->sender->lastReportedTimestamp();
|
|
|
// check if last report was at least 1 second ago
|
|
|
if (rtpConfig->timestampToSeconds(reportElapsedTimestamp) > 1) {
|
|
|
trackData->sender->setNeedsToReport();
|
|
@@ -426,7 +426,7 @@ void sendInitialNalus(shared_ptr<Stream> stream, shared_ptr<ClientTrackData> vid
|
|
|
|
|
|
// send previous NALU key frame so users don't have to wait to see stream works
|
|
|
if (!initialNalus.empty()) {
|
|
|
- const double frameDuration_s = double(h264->sampleDuration_us) / (1000 * 1000);
|
|
|
+ const double frameDuration_s = double(h264->getSampleDuration_us()) / (1000 * 1000);
|
|
|
const uint32_t frameTimestampDuration = video->sender->rtpConfig->secondsToTimestamp(frameDuration_s);
|
|
|
video->sender->rtpConfig->timestamp = video->sender->rtpConfig->startTimestamp - frameTimestampDuration * 2;
|
|
|
video->track->send(initialNalus);
|
|
@@ -447,20 +447,7 @@ void addToStream(shared_ptr<Client> client, bool isAddingVideo) {
|
|
|
|
|
|
// Audio and video tracks are collected now
|
|
|
assert(client->video.has_value() && client->audio.has_value());
|
|
|
-
|
|
|
auto video = client->video.value();
|
|
|
- auto audio = client->audio.value();
|
|
|
-
|
|
|
- auto currentTime_us = double(currentTimeInMicroSeconds());
|
|
|
- auto currentTime_s = currentTime_us / (1000 * 1000);
|
|
|
-
|
|
|
- // set start time of stream
|
|
|
- video->sender->rtpConfig->setStartTime(currentTime_s, RtpPacketizationConfig::EpochStart::T1970);
|
|
|
- audio->sender->rtpConfig->setStartTime(currentTime_s, RtpPacketizationConfig::EpochStart::T1970);
|
|
|
-
|
|
|
- // start stat recording of RTCP SR
|
|
|
- video->sender->startRecording();
|
|
|
- audio->sender->startRecording();
|
|
|
|
|
|
if (avStream.has_value()) {
|
|
|
sendInitialNalus(avStream.value(), video);
|