OLD | NEW |
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 28 matching lines...) Expand all Loading... |
39 case webrtc::kVideoCodecVP8: | 39 case webrtc::kVideoCodecVP8: |
40 return media::VP8PROFILE_ANY; | 40 return media::VP8PROFILE_ANY; |
41 case webrtc::kVideoCodecH264: { | 41 case webrtc::kVideoCodecH264: { |
42 switch (codec_settings->codecSpecific.H264.profile) { | 42 switch (codec_settings->codecSpecific.H264.profile) { |
43 case webrtc::kProfileBase: | 43 case webrtc::kProfileBase: |
44 return media::H264PROFILE_BASELINE; | 44 return media::H264PROFILE_BASELINE; |
45 case webrtc::kProfileMain: | 45 case webrtc::kProfileMain: |
46 return media::H264PROFILE_MAIN; | 46 return media::H264PROFILE_MAIN; |
47 } | 47 } |
48 } | 48 } |
49 case webrtc::kVideoCodecGeneric: | |
50 return media::H264PROFILE_MAIN; | |
51 default: | 49 default: |
52 NOTREACHED() << "Unrecognized video codec type"; | 50 NOTREACHED() << "Unrecognized video codec type"; |
53 return media::VIDEO_CODEC_PROFILE_UNKNOWN; | 51 return media::VIDEO_CODEC_PROFILE_UNKNOWN; |
54 } | 52 } |
55 } | 53 } |
56 | 54 |
57 // Populates struct webrtc::RTPFragmentationHeader for H264 codec. | 55 // Populates struct webrtc::RTPFragmentationHeader for H264 codec. |
58 // Each entry specifies the offset and length (excluding start code) of a NALU. | 56 // Each entry specifies the offset and length (excluding start code) of a NALU. |
59 // Returns true if successful. | 57 // Returns true if successful. |
60 bool GetRTPFragmentationHeaderH264(webrtc::RTPFragmentationHeader* header, | 58 bool GetRTPFragmentationHeaderH264(webrtc::RTPFragmentationHeader* header, |
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 << "bitstream_buffer_id=" << bitstream_buffer_id | 705 << "bitstream_buffer_id=" << bitstream_buffer_id |
708 << ", picture_id=" << picture_id; | 706 << ", picture_id=" << picture_id; |
709 | 707 |
710 if (!encoded_image_callback_) | 708 if (!encoded_image_callback_) |
711 return; | 709 return; |
712 | 710 |
713 webrtc::RTPFragmentationHeader header; | 711 webrtc::RTPFragmentationHeader header; |
714 memset(&header, 0, sizeof(header)); | 712 memset(&header, 0, sizeof(header)); |
715 switch (video_codec_type_) { | 713 switch (video_codec_type_) { |
716 case webrtc::kVideoCodecVP8: | 714 case webrtc::kVideoCodecVP8: |
717 case webrtc::kVideoCodecGeneric: | |
718 // Generate a header describing a single fragment. | 715 // Generate a header describing a single fragment. |
719 // Note that webrtc treats the generic-type payload as an opaque buffer. | |
720 header.VerifyAndAllocateFragmentationHeader(1); | 716 header.VerifyAndAllocateFragmentationHeader(1); |
721 header.fragmentationOffset[0] = 0; | 717 header.fragmentationOffset[0] = 0; |
722 header.fragmentationLength[0] = image->_length; | 718 header.fragmentationLength[0] = image->_length; |
723 header.fragmentationPlType[0] = 0; | 719 header.fragmentationPlType[0] = 0; |
724 header.fragmentationTimeDiff[0] = 0; | 720 header.fragmentationTimeDiff[0] = 0; |
725 break; | 721 break; |
726 case webrtc::kVideoCodecH264: | 722 case webrtc::kVideoCodecH264: |
727 if (!GetRTPFragmentationHeaderH264( | 723 if (!GetRTPFragmentationHeaderH264( |
728 &header, image->_buffer, image->_length)) { | 724 &header, image->_buffer, image->_length)) { |
729 DLOG(ERROR) << "Failed to get RTP fragmentation header for H264"; | 725 DLOG(ERROR) << "Failed to get RTP fragmentation header for H264"; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 UMA_HISTOGRAM_BOOLEAN("Media.RTCVideoEncoderInitEncodeSuccess", | 771 UMA_HISTOGRAM_BOOLEAN("Media.RTCVideoEncoderInitEncodeSuccess", |
776 init_retval == WEBRTC_VIDEO_CODEC_OK); | 772 init_retval == WEBRTC_VIDEO_CODEC_OK); |
777 if (init_retval == WEBRTC_VIDEO_CODEC_OK) { | 773 if (init_retval == WEBRTC_VIDEO_CODEC_OK) { |
778 UMA_HISTOGRAM_ENUMERATION("Media.RTCVideoEncoderProfile", | 774 UMA_HISTOGRAM_ENUMERATION("Media.RTCVideoEncoderProfile", |
779 profile, | 775 profile, |
780 media::VIDEO_CODEC_PROFILE_MAX + 1); | 776 media::VIDEO_CODEC_PROFILE_MAX + 1); |
781 } | 777 } |
782 } | 778 } |
783 | 779 |
784 } // namespace content | 780 } // namespace content |
OLD | NEW |