| 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 "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 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <functional> | 10 #include <functional> |
| (...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 795 } | 795 } |
| 796 | 796 |
| 797 media::VideoCaptureFormat capture_format(gfx::Size(max_width, max_height), | 797 media::VideoCaptureFormat capture_format(gfx::Size(max_width, max_height), |
| 798 fps, media::PIXEL_FORMAT_I420); | 798 fps, media::PIXEL_FORMAT_I420); |
| 799 | 799 |
| 800 video_config.target_frame_rate = fps; | 800 video_config.target_frame_rate = fps; |
| 801 audio_config.target_frame_rate = 100; | 801 audio_config.target_frame_rate = 100; |
| 802 | 802 |
| 803 media::AudioParameters params( | 803 media::AudioParameters params( |
| 804 media::AudioParameters::AUDIO_PCM_LINEAR, | 804 media::AudioParameters::AUDIO_PCM_LINEAR, |
| 805 media::GuessChannelLayout(audio_config.channels), | 805 media::CHANNEL_LAYOUT_STEREO, |
| 806 audio_config.rtp_timebase, // sampling rate | 806 audio_config.rtp_timebase, // sampling rate |
| 807 16, audio_config.rtp_timebase / audio_config.target_frame_rate); | 807 16, |
| 808 audio_config.rtp_timebase / audio_config.target_frame_rate); |
| 808 | 809 |
| 809 if (!params.IsValid()) { | 810 if (!params.IsValid()) { |
| 810 args.GetIsolate()->ThrowException(v8::Exception::TypeError( | 811 args.GetIsolate()->ThrowException(v8::Exception::TypeError( |
| 811 v8::String::NewFromUtf8(args.GetIsolate(), kInvalidAudioParams))); | 812 v8::String::NewFromUtf8(args.GetIsolate(), kInvalidAudioParams))); |
| 812 return; | 813 return; |
| 813 } | 814 } |
| 814 | 815 |
| 815 scoped_ptr<base::DictionaryValue> options; | 816 scoped_ptr<base::DictionaryValue> options; |
| 816 if (args.Length() >= 9) { | 817 if (args.Length() >= 9) { |
| 817 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); | 818 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 855 context()->CallFunction( | 856 context()->CallFunction( |
| 856 v8::Local<v8::Function>::New(isolate, function), 1, &arg); | 857 v8::Local<v8::Function>::New(isolate, function), 1, &arg); |
| 857 } | 858 } |
| 858 | 859 |
| 859 | 860 |
| 860 void CastStreamingNativeHandler::AddTracksToMediaStream( | 861 void CastStreamingNativeHandler::AddTracksToMediaStream( |
| 861 const std::string& url, | 862 const std::string& url, |
| 862 const media::AudioParameters& params, | 863 const media::AudioParameters& params, |
| 863 scoped_refptr<media::AudioCapturerSource> audio, | 864 scoped_refptr<media::AudioCapturerSource> audio, |
| 864 scoped_ptr<media::VideoCapturerSource> video) { | 865 scoped_ptr<media::VideoCapturerSource> video) { |
| 865 blink::WebMediaStream web_stream = | 866 content::AddAudioTrackToMediaStream(audio, params, true, true, url); |
| 866 blink::WebMediaStreamRegistry::lookupMediaStreamDescriptor(GURL(url)); | 867 content::AddVideoTrackToMediaStream(std::move(video), true, true, url); |
| 867 if (web_stream.isNull()) { | |
| 868 LOG(DFATAL) << "Stream not found."; | |
| 869 return; | |
| 870 } | |
| 871 if (!content::AddAudioTrackToMediaStream( | |
| 872 audio, params.sample_rate(), params.channel_layout(), | |
| 873 params.frames_per_buffer(), true, // is_remote | |
| 874 true, // is_readonly | |
| 875 &web_stream)) { | |
| 876 LOG(ERROR) << "Failed to add Cast audio track to media stream."; | |
| 877 } | |
| 878 if (!content::AddVideoTrackToMediaStream(std::move(video), true, // is_remote | |
| 879 true, // is_readonly | |
| 880 &web_stream)) { | |
| 881 LOG(ERROR) << "Failed to add Cast video track to media stream."; | |
| 882 } | |
| 883 } | 868 } |
| 884 | 869 |
| 885 } // namespace extensions | 870 } // namespace extensions |
| OLD | NEW |