| Index: webrtc/modules/video_coding/generic_encoder.cc
|
| diff --git a/webrtc/modules/video_coding/generic_encoder.cc b/webrtc/modules/video_coding/generic_encoder.cc
|
| index 321deb0a473f72254adbb15c365b240b1a8f54f6..9a3d2ffefaab5bb56d58c5701097188ddd0b8888 100644
|
| --- a/webrtc/modules/video_coding/generic_encoder.cc
|
| +++ b/webrtc/modules/video_coding/generic_encoder.cc
|
| @@ -21,6 +21,76 @@
|
| #include "webrtc/system_wrappers/include/critical_section_wrapper.h"
|
|
|
| namespace webrtc {
|
| +namespace {
|
| +// Map information from info into rtp. If no relevant information is found
|
| +// in info, rtp is set to NULL.
|
| +void CopyCodecSpecific(const CodecSpecificInfo* info, RTPVideoHeader* rtp) {
|
| + RTC_DCHECK(info);
|
| + switch (info->codecType) {
|
| + case kVideoCodecVP8: {
|
| + rtp->codec = kRtpVideoVp8;
|
| + rtp->codecHeader.VP8.InitRTPVideoHeaderVP8();
|
| + rtp->codecHeader.VP8.pictureId = info->codecSpecific.VP8.pictureId;
|
| + rtp->codecHeader.VP8.nonReference = info->codecSpecific.VP8.nonReference;
|
| + rtp->codecHeader.VP8.temporalIdx = info->codecSpecific.VP8.temporalIdx;
|
| + rtp->codecHeader.VP8.layerSync = info->codecSpecific.VP8.layerSync;
|
| + rtp->codecHeader.VP8.tl0PicIdx = info->codecSpecific.VP8.tl0PicIdx;
|
| + rtp->codecHeader.VP8.keyIdx = info->codecSpecific.VP8.keyIdx;
|
| + rtp->simulcastIdx = info->codecSpecific.VP8.simulcastIdx;
|
| + return;
|
| + }
|
| + case kVideoCodecVP9: {
|
| + rtp->codec = kRtpVideoVp9;
|
| + rtp->codecHeader.VP9.InitRTPVideoHeaderVP9();
|
| + rtp->codecHeader.VP9.inter_pic_predicted =
|
| + info->codecSpecific.VP9.inter_pic_predicted;
|
| + rtp->codecHeader.VP9.flexible_mode =
|
| + info->codecSpecific.VP9.flexible_mode;
|
| + rtp->codecHeader.VP9.ss_data_available =
|
| + info->codecSpecific.VP9.ss_data_available;
|
| + rtp->codecHeader.VP9.picture_id = info->codecSpecific.VP9.picture_id;
|
| + rtp->codecHeader.VP9.tl0_pic_idx = info->codecSpecific.VP9.tl0_pic_idx;
|
| + rtp->codecHeader.VP9.temporal_idx = info->codecSpecific.VP9.temporal_idx;
|
| + rtp->codecHeader.VP9.spatial_idx = info->codecSpecific.VP9.spatial_idx;
|
| + rtp->codecHeader.VP9.temporal_up_switch =
|
| + info->codecSpecific.VP9.temporal_up_switch;
|
| + rtp->codecHeader.VP9.inter_layer_predicted =
|
| + info->codecSpecific.VP9.inter_layer_predicted;
|
| + rtp->codecHeader.VP9.gof_idx = info->codecSpecific.VP9.gof_idx;
|
| + rtp->codecHeader.VP9.num_spatial_layers =
|
| + info->codecSpecific.VP9.num_spatial_layers;
|
| +
|
| + if (info->codecSpecific.VP9.ss_data_available) {
|
| + rtp->codecHeader.VP9.spatial_layer_resolution_present =
|
| + info->codecSpecific.VP9.spatial_layer_resolution_present;
|
| + if (info->codecSpecific.VP9.spatial_layer_resolution_present) {
|
| + for (size_t i = 0; i < info->codecSpecific.VP9.num_spatial_layers;
|
| + ++i) {
|
| + rtp->codecHeader.VP9.width[i] = info->codecSpecific.VP9.width[i];
|
| + rtp->codecHeader.VP9.height[i] = info->codecSpecific.VP9.height[i];
|
| + }
|
| + }
|
| + rtp->codecHeader.VP9.gof.CopyGofInfoVP9(info->codecSpecific.VP9.gof);
|
| + }
|
| +
|
| + rtp->codecHeader.VP9.num_ref_pics = info->codecSpecific.VP9.num_ref_pics;
|
| + for (int i = 0; i < info->codecSpecific.VP9.num_ref_pics; ++i)
|
| + rtp->codecHeader.VP9.pid_diff[i] = info->codecSpecific.VP9.p_diff[i];
|
| + return;
|
| + }
|
| + case kVideoCodecH264:
|
| + rtp->codec = kRtpVideoH264;
|
| + return;
|
| + case kVideoCodecGeneric:
|
| + rtp->codec = kRtpVideoGeneric;
|
| + rtp->simulcastIdx = info->codecSpecific.generic.simulcast_idx;
|
| + return;
|
| + default:
|
| + return;
|
| + }
|
| +}
|
| +} // namespace
|
| +
|
| VCMGenericEncoder::VCMGenericEncoder(
|
| VideoEncoder* encoder,
|
| VideoEncoderRateObserver* rate_observer,
|
| @@ -146,6 +216,7 @@
|
| EncodedImageCallback* post_encode_callback)
|
| : send_callback_(),
|
| media_opt_(nullptr),
|
| + payload_type_(0),
|
| internal_source_(false),
|
| post_encode_callback_(post_encode_callback) {}
|
|
|
| @@ -163,8 +234,19 @@
|
| const RTPFragmentationHeader* fragmentation_header) {
|
| TRACE_EVENT_INSTANT1("webrtc", "VCMEncodedFrameCallback::Encoded",
|
| "timestamp", encoded_image._timeStamp);
|
| - int ret_val = post_encode_callback_->Encoded(encoded_image, codec_specific,
|
| - fragmentation_header);
|
| + post_encode_callback_->Encoded(encoded_image, nullptr, nullptr);
|
| +
|
| + if (send_callback_ == nullptr)
|
| + return VCM_UNINITIALIZED;
|
| +
|
| + RTPVideoHeader rtp_video_header;
|
| + memset(&rtp_video_header, 0, sizeof(RTPVideoHeader));
|
| + if (codec_specific)
|
| + CopyCodecSpecific(codec_specific, &rtp_video_header);
|
| + rtp_video_header.rotation = encoded_image.rotation_;
|
| +
|
| + int32_t ret_val = send_callback_->SendData(
|
| + payload_type_, encoded_image, fragmentation_header, &rtp_video_header);
|
| if (ret_val < 0)
|
| return ret_val;
|
|
|
|
|