Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(610)

Unified Diff: webrtc/video/rtp_stream_receiver.cc

Issue 2565173009: Wire up H264 fmtp sprop-parameter-sets with H264SpsPpsTracker. (Closed)
Patch Set: Added comment. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/video/rtp_stream_receiver.cc
diff --git a/webrtc/video/rtp_stream_receiver.cc b/webrtc/video/rtp_stream_receiver.cc
index 73ca531b125a4d45900733d439c245fe231674d4..47e91a50f6f9c8aa7cc0b0266e75d87125117a59 100644
--- a/webrtc/video/rtp_stream_receiver.cc
+++ b/webrtc/video/rtp_stream_receiver.cc
@@ -17,6 +17,7 @@
#include "webrtc/base/logging.h"
#include "webrtc/common_types.h"
#include "webrtc/config.h"
+#include "webrtc/media/base/mediaconstants.h"
#include "webrtc/modules/pacing/packet_router.h"
#include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
#include "webrtc/modules/rtp_rtcp/include/receive_statistics.h"
@@ -26,6 +27,7 @@
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
#include "webrtc/modules/rtp_rtcp/include/ulpfec_receiver.h"
#include "webrtc/modules/video_coding/frame_object.h"
+#include "webrtc/modules/video_coding/h264_sprop_parameter_sets.h"
#include "webrtc/modules/video_coding/h264_sps_pps_tracker.h"
#include "webrtc/modules/video_coding/packet_buffer.h"
#include "webrtc/modules/video_coding/video_coding_impl.h"
@@ -223,13 +225,19 @@ RtpStreamReceiver::~RtpStreamReceiver() {
UpdateHistograms();
}
+bool RtpStreamReceiver::AddReceiveCodec(
+ const VideoCodec& video_codec,
+ const std::map<std::string, std::string>& codec_params) {
+ pt_codec_params_.insert(make_pair(video_codec.plType, codec_params));
+ return AddReceiveCodec(video_codec);
+}
+
bool RtpStreamReceiver::AddReceiveCodec(const VideoCodec& video_codec) {
int8_t old_pltype = -1;
if (rtp_payload_registry_.ReceivePayloadType(video_codec, &old_pltype) !=
-1) {
rtp_payload_registry_.DeRegisterReceivePayload(old_pltype);
}
-
return rtp_payload_registry_.RegisterReceivePayload(video_codec) == 0;
}
@@ -259,6 +267,14 @@ int32_t RtpStreamReceiver::OnReceivedPayloadData(
packet.timesNacked = nack_module_->OnReceivedPacket(packet);
if (packet.codec == kVideoCodecH264) {
+ // Only when we start to receive packets will we know what payload type
+ // that will be used. When we know the payload type insert the correct
+ // sps/pps into the tracker.
+ if (!received_rtp_packet_) {
stefan-webrtc 2016/12/19 12:05:23 Can't the payload type change in theory since we s
johan 2016/12/19 12:27:26 The payload type represents what sender and receiv
philipel 2016/12/19 12:31:27 The assumption is that there is only one VideoRece
+ received_rtp_packet_ = true;
+ InsertSpsPpsIntoTracker(packet.payloadType);
+ }
+
switch (tracker_.CopyAndFixBitstream(&packet)) {
case video_coding::H264SpsPpsTracker::kRequestKeyframe:
keyframe_request_sender_->RequestKeyFrame();
@@ -650,4 +666,25 @@ void RtpStreamReceiver::EnableReceiveRtpHeaderExtension(
StringToRtpExtensionType(extension), id));
}
+void RtpStreamReceiver::InsertSpsPpsIntoTracker(uint8_t payload_type) {
+ auto codec_params_it = pt_codec_params_.find(payload_type);
+ if (codec_params_it == pt_codec_params_.end())
+ return;
+
+ LOG(LS_INFO) << "Found out of band supplied codec paramters for"
stefan-webrtc 2016/12/19 12:05:23 codec parameters
philipel 2016/12/19 12:31:27 Done.
+ << " payload type: " << payload_type;
+
+ H264SpropParameterSets sprop_decoder;
+ auto sprop_base64_it =
+ codec_params_it->second.find(cricket::kH264FmtpSpropParameterSets);
+
+ if (sprop_base64_it == codec_params_it->second.end())
+ return;
+
+ if (!sprop_decoder.DecodeSprop(sprop_base64_it->second))
+ return;
+
+ tracker_.InsertSpsPps(sprop_decoder.sps_nalu(), sprop_decoder.pps_nalu());
+}
+
} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698