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::CHANNEL_LAYOUT_STEREO, | 805 media::GuessChannelLayout(audio_config.channels), |
806 audio_config.rtp_timebase, // sampling rate | 806 audio_config.rtp_timebase, // sampling rate |
807 16, | 807 16, audio_config.rtp_timebase / audio_config.target_frame_rate); |
808 audio_config.rtp_timebase / audio_config.target_frame_rate); | |
809 | 808 |
810 if (!params.IsValid()) { | 809 if (!params.IsValid()) { |
811 args.GetIsolate()->ThrowException(v8::Exception::TypeError( | 810 args.GetIsolate()->ThrowException(v8::Exception::TypeError( |
812 v8::String::NewFromUtf8(args.GetIsolate(), kInvalidAudioParams))); | 811 v8::String::NewFromUtf8(args.GetIsolate(), kInvalidAudioParams))); |
813 return; | 812 return; |
814 } | 813 } |
815 | 814 |
816 scoped_ptr<base::DictionaryValue> options; | 815 scoped_ptr<base::DictionaryValue> options; |
817 if (args.Length() >= 9) { | 816 if (args.Length() >= 9) { |
818 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); | 817 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
856 context()->CallFunction( | 855 context()->CallFunction( |
857 v8::Local<v8::Function>::New(isolate, function), 1, &arg); | 856 v8::Local<v8::Function>::New(isolate, function), 1, &arg); |
858 } | 857 } |
859 | 858 |
860 | 859 |
861 void CastStreamingNativeHandler::AddTracksToMediaStream( | 860 void CastStreamingNativeHandler::AddTracksToMediaStream( |
862 const std::string& url, | 861 const std::string& url, |
863 const media::AudioParameters& params, | 862 const media::AudioParameters& params, |
864 scoped_refptr<media::AudioCapturerSource> audio, | 863 scoped_refptr<media::AudioCapturerSource> audio, |
865 scoped_ptr<media::VideoCapturerSource> video) { | 864 scoped_ptr<media::VideoCapturerSource> video) { |
866 content::AddAudioTrackToMediaStream(audio, params, true, true, url); | 865 blink::WebMediaStream web_stream = |
867 content::AddVideoTrackToMediaStream(std::move(video), true, true, url); | 866 blink::WebMediaStreamRegistry::lookupMediaStreamDescriptor(GURL(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 */, &web_stream)) { |
| 875 LOG(ERROR) << "Failed to add Cast audio track to media stream."; |
| 876 } |
| 877 if (!content::AddVideoTrackToMediaStream( |
| 878 std::move(video), true /* is_remote */, true /* is_readonly */, |
| 879 &web_stream)) { |
| 880 LOG(ERROR) << "Failed to add Cast video track to media stream."; |
| 881 } |
868 } | 882 } |
869 | 883 |
870 } // namespace extensions | 884 } // namespace extensions |
OLD | NEW |