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

Side by Side Diff: chrome/renderer/extensions/cast_streaming_native_handler.cc

Issue 2068133005: Refactoring: Use enum for RtpPayloadType. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 // 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 "chrome/renderer/extensions/cast_streaming_native_handler.h" 5 #include "chrome/renderer/extensions/cast_streaming_native_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 if (!base::HexStringToBytes(input, &bytes)) 89 if (!base::HexStringToBytes(input, &bytes))
90 return false; 90 return false;
91 output->assign(reinterpret_cast<const char*>(&bytes[0]), bytes.size()); 91 output->assign(reinterpret_cast<const char*>(&bytes[0]), bytes.size());
92 return true; 92 return true;
93 } 93 }
94 } // namespace 94 } // namespace
95 95
96 bool ToCastRtpPayloadParamsOrThrow(v8::Isolate* isolate, 96 bool ToCastRtpPayloadParamsOrThrow(v8::Isolate* isolate,
97 const RtpPayloadParams& ext_params, 97 const RtpPayloadParams& ext_params,
98 CastRtpPayloadParams* cast_params) { 98 CastRtpPayloadParams* cast_params) {
99 cast_params->payload_type = ext_params.payload_type; 99 DCHECK_GE(ext_params.payload_type, media::cast::RTP_PAYLOAD_AUDIO_OPUS);
miu 2016/06/20 21:00:27 The process shouldn't crash on invalid inputs. Ins
xjz 2016/06/21 17:24:31 Ignored |ext_params.payload_type| and set the |cas
100 DCHECK_LE(ext_params.payload_type, media::cast::RTP_PAYLOAD_VIDEO_LAST);
101 cast_params->payload_type =
102 static_cast<media::cast::RtpPayloadType>(ext_params.payload_type);
103
100 cast_params->max_latency_ms = ext_params.max_latency; 104 cast_params->max_latency_ms = ext_params.max_latency;
101 cast_params->min_latency_ms = 105 cast_params->min_latency_ms =
102 ext_params.min_latency ? *ext_params.min_latency : ext_params.max_latency; 106 ext_params.min_latency ? *ext_params.min_latency : ext_params.max_latency;
103 cast_params->animated_latency_ms = ext_params.animated_latency 107 cast_params->animated_latency_ms = ext_params.animated_latency
104 ? *ext_params.animated_latency 108 ? *ext_params.animated_latency
105 : ext_params.max_latency; 109 : ext_params.max_latency;
106 cast_params->codec_name = ext_params.codec_name; 110 cast_params->codec_name = ext_params.codec_name;
107 cast_params->ssrc = ext_params.ssrc; 111 cast_params->ssrc = ext_params.ssrc;
108 cast_params->feedback_ssrc = ext_params.feedback_ssrc; 112 cast_params->feedback_ssrc = ext_params.feedback_ssrc;
109 cast_params->clock_rate = ext_params.clock_rate ? *ext_params.clock_rate : 0; 113 cast_params->clock_rate = ext_params.clock_rate ? *ext_params.clock_rate : 0;
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 config->rtp_max_delay_ms = params->max_latency; 673 config->rtp_max_delay_ms = params->max_latency;
670 if (config->rtp_max_delay_ms < 0 || config->rtp_max_delay_ms > 1000) { 674 if (config->rtp_max_delay_ms < 0 || config->rtp_max_delay_ms > 1000) {
671 isolate->ThrowException(v8::Exception::TypeError( 675 isolate->ThrowException(v8::Exception::TypeError(
672 v8::String::NewFromUtf8(isolate, kInvalidLatency))); 676 v8::String::NewFromUtf8(isolate, kInvalidLatency)));
673 return false; 677 return false;
674 } 678 }
675 config->channels = 2; 679 config->channels = 2;
676 if (params->codec_name == "OPUS") { 680 if (params->codec_name == "OPUS") {
677 config->codec = media::cast::CODEC_AUDIO_OPUS; 681 config->codec = media::cast::CODEC_AUDIO_OPUS;
678 config->rtp_timebase = 48000; 682 config->rtp_timebase = 48000;
679 config->rtp_payload_type = media::cast::kDefaultRtpAudioPayloadType; 683 config->rtp_payload_type = media::cast::RTP_PAYLOAD_AUDIO_OPUS;
680 } else if (params->codec_name == "PCM16") { 684 } else if (params->codec_name == "PCM16") {
681 config->codec = media::cast::CODEC_AUDIO_PCM16; 685 config->codec = media::cast::CODEC_AUDIO_PCM16;
682 config->rtp_timebase = 48000; 686 config->rtp_timebase = 48000;
683 config->rtp_payload_type = media::cast::kDefaultRtpAudioPayloadType; 687 config->rtp_payload_type = media::cast::RTP_PAYLOAD_AUDIO_PCM16;
684 } else if (params->codec_name == "AAC") { 688 } else if (params->codec_name == "AAC") {
685 config->codec = media::cast::CODEC_AUDIO_AAC; 689 config->codec = media::cast::CODEC_AUDIO_AAC;
686 config->rtp_timebase = 48000; 690 config->rtp_timebase = 48000;
687 config->rtp_payload_type = media::cast::kDefaultRtpAudioPayloadType; 691 config->rtp_payload_type = media::cast::RTP_PAYLOAD_AUDIO_AAC;
688 } else if (params->codec_name == "VP8") { 692 } else if (params->codec_name == "VP8") {
689 config->codec = media::cast::CODEC_VIDEO_VP8; 693 config->codec = media::cast::CODEC_VIDEO_VP8;
690 config->rtp_timebase = 90000; 694 config->rtp_timebase = 90000;
691 config->rtp_payload_type = media::cast::kDefaultRtpVideoPayloadType; 695 config->rtp_payload_type = media::cast::RTP_PAYLOAD_VIDEO_VP8;
692 } else if (params->codec_name == "H264") { 696 } else if (params->codec_name == "H264") {
693 config->codec = media::cast::CODEC_VIDEO_H264; 697 config->codec = media::cast::CODEC_VIDEO_H264;
694 config->rtp_timebase = 90000; 698 config->rtp_timebase = 90000;
695 config->rtp_payload_type = media::cast::kDefaultRtpVideoPayloadType; 699 config->rtp_payload_type = media::cast::RTP_PAYLOAD_VIDEO_H264;
696 } 700 }
697 if (params->rtp_timebase) { 701 if (params->rtp_timebase) {
698 config->rtp_timebase = *params->rtp_timebase; 702 config->rtp_timebase = *params->rtp_timebase;
699 if (config->rtp_timebase < 1000 || config->rtp_timebase > 1000000) { 703 if (config->rtp_timebase < 1000 || config->rtp_timebase > 1000000) {
700 isolate->ThrowException(v8::Exception::TypeError( 704 isolate->ThrowException(v8::Exception::TypeError(
701 v8::String::NewFromUtf8(isolate, kInvalidRtpTimebase))); 705 v8::String::NewFromUtf8(isolate, kInvalidRtpTimebase)));
702 return false; 706 return false;
703 } 707 }
704 } 708 }
705 if (params->aes_key && 709 if (params->aes_key &&
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 LOG(ERROR) << "Failed to add Cast audio track to media stream."; 881 LOG(ERROR) << "Failed to add Cast audio track to media stream.";
878 } 882 }
879 if (!content::AddVideoTrackToMediaStream(std::move(video), true, // is_remote 883 if (!content::AddVideoTrackToMediaStream(std::move(video), true, // is_remote
880 true, // is_readonly 884 true, // is_readonly
881 &web_stream)) { 885 &web_stream)) {
882 LOG(ERROR) << "Failed to add Cast video track to media stream."; 886 LOG(ERROR) << "Failed to add Cast video track to media stream.";
883 } 887 }
884 } 888 }
885 889
886 } // namespace extensions 890 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698