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

Side by Side Diff: webrtc/modules/video_coding/generic_decoder.cc

Issue 2772033002: Add content type information to encoded images and corresponding rtp extension header (Closed)
Patch Set: Fix typo, leading to failed video catpure test Created 3 years, 8 months 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 if (!decode_time_ms) { 80 if (!decode_time_ms) {
81 decode_time_ms = 81 decode_time_ms =
82 rtc::Optional<int32_t>(now_ms - frameInfo->decodeStartTimeMs); 82 rtc::Optional<int32_t>(now_ms - frameInfo->decodeStartTimeMs);
83 } 83 }
84 _timing->StopDecodeTimer(decodedImage.timestamp(), *decode_time_ms, now_ms, 84 _timing->StopDecodeTimer(decodedImage.timestamp(), *decode_time_ms, now_ms,
85 frameInfo->renderTimeMs); 85 frameInfo->renderTimeMs);
86 86
87 decodedImage.set_timestamp_us( 87 decodedImage.set_timestamp_us(
88 frameInfo->renderTimeMs * rtc::kNumMicrosecsPerMillisec); 88 frameInfo->renderTimeMs * rtc::kNumMicrosecsPerMillisec);
89 decodedImage.set_rotation(frameInfo->rotation); 89 decodedImage.set_rotation(frameInfo->rotation);
90 _receiveCallback->FrameToRender(decodedImage, qp); 90 _receiveCallback->FrameToRender(decodedImage, qp, frameInfo->content_type);
91 } 91 }
92 92
93 int32_t VCMDecodedFrameCallback::ReceivedDecodedReferenceFrame( 93 int32_t VCMDecodedFrameCallback::ReceivedDecodedReferenceFrame(
94 const uint64_t pictureId) { 94 const uint64_t pictureId) {
95 return _receiveCallback->ReceivedDecodedReferenceFrame(pictureId); 95 return _receiveCallback->ReceivedDecodedReferenceFrame(pictureId);
96 } 96 }
97 97
98 int32_t VCMDecodedFrameCallback::ReceivedDecodedFrame( 98 int32_t VCMDecodedFrameCallback::ReceivedDecodedFrame(
99 const uint64_t pictureId) { 99 const uint64_t pictureId) {
100 _lastReceivedPictureID = pictureId; 100 _lastReceivedPictureID = pictureId;
(...skipping 23 matching lines...) Expand all
124 return VCM_OK; 124 return VCM_OK;
125 } 125 }
126 126
127 VCMGenericDecoder::VCMGenericDecoder(VideoDecoder* decoder, bool isExternal) 127 VCMGenericDecoder::VCMGenericDecoder(VideoDecoder* decoder, bool isExternal)
128 : _callback(NULL), 128 : _callback(NULL),
129 _frameInfos(), 129 _frameInfos(),
130 _nextFrameInfoIdx(0), 130 _nextFrameInfoIdx(0),
131 _decoder(decoder), 131 _decoder(decoder),
132 _codecType(kVideoCodecUnknown), 132 _codecType(kVideoCodecUnknown),
133 _isExternal(isExternal), 133 _isExternal(isExternal),
134 _keyFrameDecoded(false) {} 134 _keyFrameDecoded(false),
135 _last_keyframe_content_type(VideoContentType::UNSPECIFIED) {}
135 136
136 VCMGenericDecoder::~VCMGenericDecoder() {} 137 VCMGenericDecoder::~VCMGenericDecoder() {}
137 138
138 int32_t VCMGenericDecoder::InitDecode(const VideoCodec* settings, 139 int32_t VCMGenericDecoder::InitDecode(const VideoCodec* settings,
139 int32_t numberOfCores) { 140 int32_t numberOfCores) {
140 TRACE_EVENT0("webrtc", "VCMGenericDecoder::InitDecode"); 141 TRACE_EVENT0("webrtc", "VCMGenericDecoder::InitDecode");
141 _codecType = settings->codecType; 142 _codecType = settings->codecType;
142 143
143 return _decoder->InitDecode(settings, numberOfCores); 144 return _decoder->InitDecode(settings, numberOfCores);
144 } 145 }
145 146
146 int32_t VCMGenericDecoder::Decode(const VCMEncodedFrame& frame, int64_t nowMs) { 147 int32_t VCMGenericDecoder::Decode(const VCMEncodedFrame& frame, int64_t nowMs) {
147 TRACE_EVENT1("webrtc", "VCMGenericDecoder::Decode", "timestamp", 148 TRACE_EVENT1("webrtc", "VCMGenericDecoder::Decode", "timestamp",
148 frame.EncodedImage()._timeStamp); 149 frame.EncodedImage()._timeStamp);
149 _frameInfos[_nextFrameInfoIdx].decodeStartTimeMs = nowMs; 150 _frameInfos[_nextFrameInfoIdx].decodeStartTimeMs = nowMs;
150 _frameInfos[_nextFrameInfoIdx].renderTimeMs = frame.RenderTimeMs(); 151 _frameInfos[_nextFrameInfoIdx].renderTimeMs = frame.RenderTimeMs();
151 _frameInfos[_nextFrameInfoIdx].rotation = frame.rotation(); 152 _frameInfos[_nextFrameInfoIdx].rotation = frame.rotation();
153 // Set correctly only for key frames. Thus, use latest key frame
154 // content type. If the corresponding key frame was lost, decode will fail
155 // and content type will be ignored.
156 if (frame.FrameType() == kVideoFrameKey) {
157 _frameInfos[_nextFrameInfoIdx].content_type = frame.contentType();
158 _last_keyframe_content_type = frame.contentType();
159 } else {
160 _frameInfos[_nextFrameInfoIdx].content_type = _last_keyframe_content_type;
161 }
152 _callback->Map(frame.TimeStamp(), &_frameInfos[_nextFrameInfoIdx]); 162 _callback->Map(frame.TimeStamp(), &_frameInfos[_nextFrameInfoIdx]);
153 163
154 _nextFrameInfoIdx = (_nextFrameInfoIdx + 1) % kDecoderFrameMemoryLength; 164 _nextFrameInfoIdx = (_nextFrameInfoIdx + 1) % kDecoderFrameMemoryLength;
155 const RTPFragmentationHeader dummy_header; 165 const RTPFragmentationHeader dummy_header;
156 int32_t ret = _decoder->Decode(frame.EncodedImage(), frame.MissingFrame(), 166 int32_t ret = _decoder->Decode(frame.EncodedImage(), frame.MissingFrame(),
157 &dummy_header, 167 &dummy_header,
158 frame.CodecSpecific(), frame.RenderTimeMs()); 168 frame.CodecSpecific(), frame.RenderTimeMs());
159 169
160 _callback->OnDecoderImplementationName(_decoder->ImplementationName()); 170 _callback->OnDecoderImplementationName(_decoder->ImplementationName());
161 if (ret < WEBRTC_VIDEO_CODEC_OK) { 171 if (ret < WEBRTC_VIDEO_CODEC_OK) {
(...skipping 21 matching lines...) Expand all
183 193
184 bool VCMGenericDecoder::External() const { 194 bool VCMGenericDecoder::External() const {
185 return _isExternal; 195 return _isExternal;
186 } 196 }
187 197
188 bool VCMGenericDecoder::PrefersLateDecoding() const { 198 bool VCMGenericDecoder::PrefersLateDecoding() const {
189 return _decoder->PrefersLateDecoding(); 199 return _decoder->PrefersLateDecoding();
190 } 200 }
191 201
192 } // namespace webrtc 202 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/generic_decoder.h ('k') | webrtc/modules/video_coding/include/mock/mock_vcm_callbacks.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698