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

Side by Side Diff: content/renderer/media/rtc_video_encoder.cc

Issue 647613007: RtcVideoEncoder: determine video codec profile at InitEncode time. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « content/renderer/media/rtc_video_encoder.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/media/rtc_video_encoder.h" 5 #include "content/renderer/media/rtc_video_encoder.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_vector.h" 10 #include "base/memory/scoped_vector.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 header->VerifyAndAllocateFragmentationHeader(nalu_vector.size()); 55 header->VerifyAndAllocateFragmentationHeader(nalu_vector.size());
56 for (size_t i = 0; i < nalu_vector.size(); ++i) { 56 for (size_t i = 0; i < nalu_vector.size(); ++i) {
57 header->fragmentationOffset[i] = nalu_vector[i].data - data; 57 header->fragmentationOffset[i] = nalu_vector[i].data - data;
58 header->fragmentationLength[i] = nalu_vector[i].size; 58 header->fragmentationLength[i] = nalu_vector[i].size;
59 header->fragmentationPlType[i] = 0; 59 header->fragmentationPlType[i] = 0;
60 header->fragmentationTimeDiff[i] = 0; 60 header->fragmentationTimeDiff[i] = 0;
61 } 61 }
62 return true; 62 return true;
63 } 63 }
64 64
65 // Maps webrtc::VideoCodecProfile to media::VideoCodecProfile for H264 codec.
Pawel Osciak 2014/10/20 06:28:43 Could we instead have a method that takes both pro
hshi1 2014/10/20 16:55:50 The |profile_| is of media::VideoCodecProfile type
Pawel Osciak 2014/10/21 13:41:46 Yes. My suggestion though was that it would be nic
hshi1 2014/10/22 19:01:16 Done.
66 media::VideoCodecProfile GetH264CodecProfile(
67 webrtc::VideoCodecProfile profile) {
68 switch (profile) {
69 case webrtc::kProfileBase:
70 return media::H264PROFILE_BASELINE;
Pawel Osciak 2014/10/20 06:28:43 Is this actually baseline or constrained baseline?
hshi1 2014/10/20 16:55:50 This is the actual baseline, however as I commente
Pawel Osciak 2014/10/21 13:41:46 The issue is, what if an encoder does non-constrai
hshi1 2014/10/22 19:01:16 But there's no constrained baseline profile defini
Pawel Osciak 2014/10/25 01:29:57 Right, but that's a bug (crbug.com/345569) so perh
71 case webrtc::kProfileMain:
72 return media::H264PROFILE_MAIN;
73 default:
74 DLOG(ERROR) << "Unrecognized H264 video codec profile";
75 }
76 return media::H264PROFILE_BASELINE;
Pawel Osciak 2014/10/20 06:28:43 notreached.
hshi1 2014/10/20 16:55:50 Acknowledged.
77 }
78
65 } // namespace 79 } // namespace
66 80
67 // This private class of RTCVideoEncoder does the actual work of communicating 81 // This private class of RTCVideoEncoder does the actual work of communicating
68 // with a media::VideoEncodeAccelerator for handling video encoding. It can 82 // with a media::VideoEncodeAccelerator for handling video encoding. It can
69 // be created on any thread, but should subsequently be posted to (and Destroy() 83 // be created on any thread, but should subsequently be posted to (and Destroy()
70 // called on) a single thread. Callbacks to RTCVideoEncoder are posted to the 84 // called on) a single thread. Callbacks to RTCVideoEncoder are posted to the
71 // thread on which the instance was constructed. 85 // thread on which the instance was constructed.
72 // 86 //
73 // This class separates state related to the thread that RTCVideoEncoder 87 // This class separates state related to the thread that RTCVideoEncoder
74 // operates on (presently the libjingle worker thread) from the thread that 88 // operates on (presently the libjingle worker thread) from the thread that
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 int32_t RTCVideoEncoder::InitEncode(const webrtc::VideoCodec* codec_settings, 581 int32_t RTCVideoEncoder::InitEncode(const webrtc::VideoCodec* codec_settings,
568 int32_t number_of_cores, 582 int32_t number_of_cores,
569 uint32_t max_payload_size) { 583 uint32_t max_payload_size) {
570 DVLOG(1) << "InitEncode(): codecType=" << codec_settings->codecType 584 DVLOG(1) << "InitEncode(): codecType=" << codec_settings->codecType
571 << ", width=" << codec_settings->width 585 << ", width=" << codec_settings->width
572 << ", height=" << codec_settings->height 586 << ", height=" << codec_settings->height
573 << ", startBitrate=" << codec_settings->startBitrate; 587 << ", startBitrate=" << codec_settings->startBitrate;
574 DCHECK(thread_checker_.CalledOnValidThread()); 588 DCHECK(thread_checker_.CalledOnValidThread());
575 DCHECK(!impl_.get()); 589 DCHECK(!impl_.get());
576 590
591 if (codec_settings->codecType == webrtc::kVideoCodecH264) {
Pawel Osciak 2014/10/20 06:28:43 If we can't determine profile on construction, can
hshi1 2014/10/20 16:55:50 No we can't because of the way webRTC defines the
Pawel Osciak 2014/10/21 13:41:46 We could perhaps store webrtc codec in RTCVE const
hshi1 2014/10/22 19:01:16 Done.
592 video_codec_profile_ =
593 GetH264CodecProfile(codec_settings->codecSpecific.H264.profile);
594 }
595
577 weak_factory_.InvalidateWeakPtrs(); 596 weak_factory_.InvalidateWeakPtrs();
578 impl_ = new Impl(weak_factory_.GetWeakPtr(), gpu_factories_); 597 impl_ = new Impl(weak_factory_.GetWeakPtr(), gpu_factories_);
579 base::WaitableEvent initialization_waiter(true, false); 598 base::WaitableEvent initialization_waiter(true, false);
580 int32_t initialization_retval = WEBRTC_VIDEO_CODEC_UNINITIALIZED; 599 int32_t initialization_retval = WEBRTC_VIDEO_CODEC_UNINITIALIZED;
581 gpu_factories_->GetTaskRunner()->PostTask( 600 gpu_factories_->GetTaskRunner()->PostTask(
582 FROM_HERE, 601 FROM_HERE,
583 base::Bind(&RTCVideoEncoder::Impl::CreateAndInitializeVEA, 602 base::Bind(&RTCVideoEncoder::Impl::CreateAndInitializeVEA,
584 impl_, 603 impl_,
585 gfx::Size(codec_settings->width, codec_settings->height), 604 gfx::Size(codec_settings->width, codec_settings->height),
586 codec_settings->startBitrate, 605 codec_settings->startBitrate,
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 UMA_HISTOGRAM_BOOLEAN("Media.RTCVideoEncoderInitEncodeSuccess", 768 UMA_HISTOGRAM_BOOLEAN("Media.RTCVideoEncoderInitEncodeSuccess",
750 init_retval == WEBRTC_VIDEO_CODEC_OK); 769 init_retval == WEBRTC_VIDEO_CODEC_OK);
751 if (init_retval == WEBRTC_VIDEO_CODEC_OK) { 770 if (init_retval == WEBRTC_VIDEO_CODEC_OK) {
752 UMA_HISTOGRAM_ENUMERATION("Media.RTCVideoEncoderProfile", 771 UMA_HISTOGRAM_ENUMERATION("Media.RTCVideoEncoderProfile",
753 video_codec_profile_, 772 video_codec_profile_,
754 media::VIDEO_CODEC_PROFILE_MAX + 1); 773 media::VIDEO_CODEC_PROFILE_MAX + 1);
755 } 774 }
756 } 775 }
757 776
758 } // namespace content 777 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/rtc_video_encoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698