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

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

Issue 14312015: Effects Pepper Plugin and MediaStream Glue. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/media_stream_dependency_factory.h" 5 #include "content/renderer/media/media_stream_dependency_factory.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/synchronization/waitable_event.h" 9 #include "base/synchronization/waitable_event.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 22 matching lines...) Expand all
33 #endif 33 #endif
34 34
35 namespace content { 35 namespace content {
36 36
37 // Constant constraint keys which disables all audio constraints. 37 // Constant constraint keys which disables all audio constraints.
38 // Only used in combination with WebAudio sources. 38 // Only used in combination with WebAudio sources.
39 struct { 39 struct {
40 const char* key; 40 const char* key;
41 const char* value; 41 const char* value;
42 } const kWebAudioConstraints[] = { 42 } const kWebAudioConstraints[] = {
43 {webrtc::MediaConstraintsInterface::kEchoCancellation, 43 {webrtc::MediaConstraintsInterface::kEchoCancellation,
44 webrtc::MediaConstraintsInterface::kValueFalse}, 44 webrtc::MediaConstraintsInterface::kValueFalse},
45 {webrtc::MediaConstraintsInterface::kAutoGainControl, 45 {webrtc::MediaConstraintsInterface::kAutoGainControl,
46 webrtc::MediaConstraintsInterface::kValueFalse}, 46 webrtc::MediaConstraintsInterface::kValueFalse},
47 {webrtc::MediaConstraintsInterface::kNoiseSuppression, 47 {webrtc::MediaConstraintsInterface::kNoiseSuppression,
48 webrtc::MediaConstraintsInterface::kValueFalse}, 48 webrtc::MediaConstraintsInterface::kValueFalse},
49 {webrtc::MediaConstraintsInterface::kHighpassFilter, 49 {webrtc::MediaConstraintsInterface::kHighpassFilter,
50 webrtc::MediaConstraintsInterface::kValueFalse}, 50 webrtc::MediaConstraintsInterface::kValueFalse},
51 }; 51 };
52 52
53 class WebAudioConstraints : public RTCMediaConstraints { 53 class WebAudioConstraints : public RTCMediaConstraints {
54 public: 54 public:
55 WebAudioConstraints() 55 WebAudioConstraints()
56 : RTCMediaConstraints(WebKit::WebMediaConstraints()) { 56 : RTCMediaConstraints(WebKit::WebMediaConstraints()) {
57 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kWebAudioConstraints); ++i) { 57 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kWebAudioConstraints); ++i) {
58 webrtc::MediaConstraintsInterface::Constraint constraint; 58 webrtc::MediaConstraintsInterface::Constraint constraint;
59 constraint.key = kWebAudioConstraints[i].key; 59 constraint.key = kWebAudioConstraints[i].key;
60 constraint.value = kWebAudioConstraints[i].value; 60 constraint.value = kWebAudioConstraints[i].value;
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 } 394 }
395 return native_stream->AddTrack(audio_track); 395 return native_stream->AddTrack(audio_track);
396 } else { 396 } else {
397 scoped_refptr<webrtc::VideoTrackInterface> video_track( 397 scoped_refptr<webrtc::VideoTrackInterface> video_track(
398 CreateLocalVideoTrack(track_id, source_data->video_source())); 398 CreateLocalVideoTrack(track_id, source_data->video_source()));
399 video_track->set_enabled(track.isEnabled()); 399 video_track->set_enabled(track.isEnabled());
400 return native_stream->AddTrack(video_track); 400 return native_stream->AddTrack(video_track);
401 } 401 }
402 } 402 }
403 403
404 bool MediaStreamDependencyFactory::AddNativeVideoMediaTrack(
405 const std::string& track_id,
406 WebKit::WebMediaStream* stream,
407 cricket::VideoCapturer* capturer) {
408 if (!stream) {
409 LOG(ERROR) << "AddNativeVideoMediaTrack called with null WebMediaStream.";
410 return false;
411 }
412
413 // Create native track from the source.
414 scoped_refptr<webrtc::VideoTrackInterface> native_track =
415 CreateLocalVideoTrack(track_id, capturer);
416
417 // Add the native track to native stream
418 MediaStreamExtraData* extra_data =
419 static_cast<MediaStreamExtraData*>(stream->extraData());
420 DCHECK(extra_data);
421 webrtc::MediaStreamInterface* native_stream = extra_data->stream();
422 native_stream->AddTrack(native_track);
423
424 // Create a new webkit video track.
425 WebKit::WebMediaStreamTrack webkit_track;
426 WebKit::WebMediaStreamSource webkit_source;
427 WebKit::WebString webkit_track_id(UTF8ToUTF16(track_id));
428 WebKit::WebMediaStreamSource::Type type =
429 WebKit::WebMediaStreamSource::TypeVideo;
430 webkit_source.initialize(webkit_track_id, type, webkit_track_id);
431 webkit_track.initialize(webkit_track_id, webkit_source);
432
433 // Add the track to WebMediaStream.
434 stream->addTrack(webkit_track);
435 return true;
436 }
437
404 bool MediaStreamDependencyFactory::RemoveNativeMediaStreamTrack( 438 bool MediaStreamDependencyFactory::RemoveNativeMediaStreamTrack(
405 const WebKit::WebMediaStream& stream, 439 const WebKit::WebMediaStream& stream,
406 const WebKit::WebMediaStreamTrack& track) { 440 const WebKit::WebMediaStreamTrack& track) {
407 MediaStreamExtraData* extra_data = 441 MediaStreamExtraData* extra_data =
408 static_cast<MediaStreamExtraData*>(stream.extraData()); 442 static_cast<MediaStreamExtraData*>(stream.extraData());
409 webrtc::MediaStreamInterface* native_stream = extra_data->stream(); 443 webrtc::MediaStreamInterface* native_stream = extra_data->stream();
410 DCHECK(native_stream); 444 DCHECK(native_stream);
411 445
412 WebKit::WebMediaStreamSource::Type type = track.source().type(); 446 WebKit::WebMediaStreamSource::Type type = track.source().type();
413 DCHECK(type == WebKit::WebMediaStreamSource::TypeAudio || 447 DCHECK(type == WebKit::WebMediaStreamSource::TypeAudio ||
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 return true; 580 return true;
547 } 581 }
548 582
549 scoped_refptr<webrtc::VideoTrackInterface> 583 scoped_refptr<webrtc::VideoTrackInterface>
550 MediaStreamDependencyFactory::CreateLocalVideoTrack( 584 MediaStreamDependencyFactory::CreateLocalVideoTrack(
551 const std::string& id, 585 const std::string& id,
552 webrtc::VideoSourceInterface* source) { 586 webrtc::VideoSourceInterface* source) {
553 return pc_factory_->CreateVideoTrack(id, source).get(); 587 return pc_factory_->CreateVideoTrack(id, source).get();
554 } 588 }
555 589
590 scoped_refptr<webrtc::VideoTrackInterface>
591 MediaStreamDependencyFactory::CreateLocalVideoTrack(
592 const std::string& id, cricket::VideoCapturer* capturer) {
593 if (!capturer) {
594 LOG(ERROR) << "CreateLocalVideoTrack called with null VideoCapturer.";
595 return NULL;
596 }
597
598 // Create video source from the |capturer|.
599 scoped_refptr<webrtc::VideoSourceInterface> source =
600 pc_factory_->CreateVideoSource(capturer, NULL).get();
601
602 // Create native track from the source.
603 return pc_factory_->CreateVideoTrack(id, source).get();
604 }
605
556 scoped_refptr<webrtc::AudioTrackInterface> 606 scoped_refptr<webrtc::AudioTrackInterface>
557 MediaStreamDependencyFactory::CreateLocalAudioTrack( 607 MediaStreamDependencyFactory::CreateLocalAudioTrack(
558 const std::string& id, 608 const std::string& id,
559 webrtc::AudioSourceInterface* source) { 609 webrtc::AudioSourceInterface* source) {
560 return pc_factory_->CreateAudioTrack(id, source).get(); 610 return pc_factory_->CreateAudioTrack(id, source).get();
561 } 611 }
562 612
563 webrtc::SessionDescriptionInterface* 613 webrtc::SessionDescriptionInterface*
564 MediaStreamDependencyFactory::CreateSessionDescription( 614 MediaStreamDependencyFactory::CreateSessionDescription(
565 const std::string& type, 615 const std::string& type,
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 // processed before returning. We wait for the above task to finish before 742 // processed before returning. We wait for the above task to finish before
693 // letting the the function continue to avoid any potential race issues. 743 // letting the the function continue to avoid any potential race issues.
694 chrome_worker_thread_.Stop(); 744 chrome_worker_thread_.Stop();
695 } else { 745 } else {
696 NOTREACHED() << "Worker thread not running."; 746 NOTREACHED() << "Worker thread not running.";
697 } 747 }
698 } 748 }
699 } 749 }
700 750
701 } // namespace content 751 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698