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

Unified Diff: webrtc/modules/video_coding/frame_object.cc

Issue 2916433003: Check H264 NALUs for frametype and insert SPS/PPS packets into the PacketBuffer. (Closed)
Patch Set: Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | webrtc/modules/video_coding/h264_sps_pps_tracker.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/video_coding/frame_object.cc
diff --git a/webrtc/modules/video_coding/frame_object.cc b/webrtc/modules/video_coding/frame_object.cc
index aa6b837f363aa2e3f5db880ab58b571d3319fb5e..449915728ca15b2f7c16891a8eacf246cfb57226 100644
--- a/webrtc/modules/video_coding/frame_object.cc
+++ b/webrtc/modules/video_coding/frame_object.cc
@@ -9,6 +9,7 @@
*/
#include "webrtc/base/checks.h"
+#include "webrtc/common_video/h264/h264_common.h"
#include "webrtc/modules/video_coding/frame_object.h"
#include "webrtc/modules/video_coding/packet_buffer.h"
@@ -65,7 +66,32 @@ RtpFrameObject::RtpFrameObject(PacketBuffer* packet_buffer,
_buffer = new uint8_t[_size];
_length = frame_size;
- _frameType = first_packet->frameType;
+
+ // For H264 frames we can't determine the frame type by just looking at the
+ // first packet. Instead we consider the frame to be a keyframe if it
+ // contains an IDR NALU.
+ if (codec_type_ == kVideoCodecH264) {
+ _frameType = kVideoFrameDelta;
+ frame_type_ = kVideoFrameDelta;
+ for (uint16_t seq_num = first_seq_num;
+ seq_num != last_seq_num + 1 && _frameType == kVideoFrameDelta;
+ ++seq_num) {
+ VCMPacket* packet = packet_buffer_->GetPacket(seq_num);
+ RTC_DCHECK(packet);
+ const RTPVideoHeaderH264& header = packet->video_header.codecHeader.H264;
+ for (size_t i = 0; i < header.nalus_length; ++i) {
+ if (header.nalus[i].type == H264::NaluType::kIdr) {
+ _frameType = kVideoFrameKey;
+ frame_type_ = kVideoFrameKey;
+ break;
+ }
+ }
+ }
+ } else {
+ _frameType = first_packet->frameType;
+ frame_type_ = first_packet->frameType;
+ }
+
GetBitstream(_buffer);
_encodedWidth = first_packet->width;
_encodedHeight = first_packet->height;
« no previous file with comments | « no previous file | webrtc/modules/video_coding/h264_sps_pps_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698