void RtcStream::SetupLocalStream(bool enableVoice, bool enableVideo, bool enableData) { if ( enableVoice == false && enableVideo == false && enableData == false) return; talk_base::scoped_refptr<webrtc::MediaStreamInterface> stream = factory_->CreateLocalMediaStream("simple_stream"); if ( enableVoice) { talk_base::scoped_refptr<webrtc::AudioTrackInterface> audio_track( factory_->CreateAudioTrack( "simple_voice", factory_->CreateAudioSource(NULL))); stream->AddTrack(audio_track); } //videoCapturer_ = OpenVideoCaptureDevice(); //videoCapturer_->set_enable_video_adapter(false); if ( enableVideo && videoCapturer_ != NULL) { talk_base::scoped_refptr<webrtc::VideoSourceInterface> video_source( factory_->CreateVideoSource(videoCapturer_, NULL)); talk_base::scoped_refptr<webrtc::VideoTrackInterface> video_track( factory_->CreateVideoTrack( "simple_video", video_source)); stream->AddTrack(video_track); } if ( enableVoice || enableVideo ) connection_->AddStream(stream, NULL); if ( enableData ) { webrtc::DataChannelInit dcSetting; data_channel_ = connection_->CreateDataChannel("abmedia", &dcSetting); data_channel_->RegisterObserver(this); } }
ActivityManager::ActivityManager(QObject *parent) :QObject(parent) { _conductorOne = new talk_base::RefCountedObject<Conductor>(this,"ONE"); _conductorTwo = new talk_base::RefCountedObject<Conductor>(this,"TWO"); QObject::connect(_conductorOne,SIGNAL(sendBye()),_conductorTwo,SLOT(callbackBye())); QObject::connect(_conductorOne,SIGNAL(sendDescription(std::string,std::string)), _conductorTwo,SLOT(callbackDescription(std::string,std::string))); QObject::connect(_conductorOne,SIGNAL(sendCandidate(std::string,int,std::string)), _conductorTwo,SLOT(callbackCandidate(std::string,int,std::string))); QObject::connect(_conductorTwo,SIGNAL(sendBye()),_conductorOne,SLOT(callbackBye())); QObject::connect(_conductorTwo,SIGNAL(sendDescription(std::string,std::string)), _conductorOne,SLOT(callbackDescription(std::string,std::string))); QObject::connect(_conductorTwo,SIGNAL(sendCandidate(std::string,int,std::string)), _conductorOne,SLOT(callbackCandidate(std::string,int,std::string))); _peer_connection_factory = webrtc::CreatePeerConnectionFactory(); talk_base::scoped_refptr<webrtc::AudioTrackInterface> audio_track(_peer_connection_factory->CreateAudioTrack("Audio", _peer_connection_factory->CreateAudioSource(NULL))); talk_base::scoped_refptr<webrtc::VideoTrackInterface> video_track( _peer_connection_factory->CreateVideoTrack("Video",_peer_connection_factory->CreateVideoSource(OpenVideoCaptureDevice(),NULL))); _globalstream = _peer_connection_factory->CreateLocalMediaStream("Stream"); _globalstream->AddTrack(audio_track); _globalstream->AddTrack(video_track); }
void PeerConnectionManager::AddStreams(webrtc::PeerConnectionInterface* peer_connection, const std::string & url) { cricket::VideoCapturer* capturer = OpenVideoCaptureDevice(url); if (!capturer) { LOG(LS_ERROR) << "Cannot create capturer " << url; } else { VideoCapturerListener listener(capturer); rtc::scoped_refptr<webrtc::VideoSourceInterface> source = peer_connection_factory_->CreateVideoSource(capturer, NULL); rtc::scoped_refptr<webrtc::VideoTrackInterface> video_track(peer_connection_factory_->CreateVideoTrack(kVideoLabel, source)); rtc::scoped_refptr<webrtc::MediaStreamInterface> stream = peer_connection_factory_->CreateLocalMediaStream(kStreamLabel); if (!stream.get()) { LOG(LS_ERROR) << "Cannot create stream"; } else { stream->AddTrack(video_track); if (!peer_connection->AddStream(stream)) { LOG(LS_ERROR) << "Adding stream to PeerConnection failed"; } } } }
void RtcStream::SetupLocalStream(bool enableVoice, bool enableVideo) { if ( enableVoice == false && enableVideo == false) return; talk_base::scoped_refptr<webrtc::MediaStreamInterface> stream = factory_->CreateLocalMediaStream("simple_stream"); if ( enableVoice) { #ifdef GOOGLE_ENGINE talk_base::scoped_refptr<webrtc::AudioTrackInterface> audio_track( factory_->CreateAudioTrack( "simple_voice", factory_->CreateAudioSource(NULL))); #else talk_base::scoped_refptr<webrtc::AudioTrackInterface> audio_track( factory_->CreateAudioTrack( "mixer_voice", NULL)); #endif stream->AddTrack( audio_track); } if ( enableVideo) { #ifdef GOOGLE_ENGINE talk_base::scoped_refptr<webrtc::VideoTrackInterface> video_track( factory_->CreateVideoTrack( "simplertc", factory_->CreateVideoSource(OpenVideoCaptureDevice(), NULL))); stream->AddTrack( video_track); #else talk_base::scoped_refptr<webrtc::VideoTrackInterface> video_track( factory_->CreateVideoTrack( "mixer_video", NULL)); stream->AddTrack( video_track); #endif } connection_->AddStream(stream, NULL); }
void RTCPeer::createStreams(){ rtc::scoped_refptr<webrtc::AudioTrackInterface> audio_track( peerConnectionFactory->CreateAudioTrack(kAudioLabel, peerConnectionFactory->CreateAudioSource(NULL))); rtc::scoped_refptr<webrtc::VideoTrackInterface> video_track( peerConnectionFactory->CreateVideoTrack(kVideoLabel,peerConnectionFactory->CreateVideoSource(OpenVideoCaptureDevice(), NULL))); // <---- can start local renderer here if needed rtc::scoped_refptr<webrtc::MediaStreamInterface> stream(peerConnectionFactory->CreateLocalMediaStream(kStreamLabel)); stream->AddTrack(audio_track); stream->AddTrack(video_track); streams["video"] = stream; }
bool PeerManager::AddStreams(webrtc::PeerConnectionInterface* peer_connection) { if (media_stream.get() == NULL) { cricket::VideoCapturer *capturer = OpenVideoCaptureDevice(); if (!capturer) { UMBO_WARN("Cannot create capturer"); return false; } // Register video capturer listener //VideoCapturerListener listener(capturer); // Create media stream media_stream = peer_connection_factory->CreateLocalMediaStream(STREAM_LABEL); if (!media_stream.get()) { UMBO_WARN("Fail to create stream"); return false; } // Create video track rtc::scoped_refptr<webrtc::VideoTrackInterface> video_track( peer_connection_factory->CreateVideoTrack(VIDEO_LABEL, peer_connection_factory->CreateVideoSource(capturer, NULL)) ); // Create audio track rtc::scoped_refptr<webrtc::AudioTrackInterface> audio_track( peer_connection_factory->CreateAudioTrack(AUDIO_LABEL, peer_connection_factory->CreateAudioSource(NULL)) ); if (!media_stream->AddTrack(video_track)) { UMBO_WARN("Fail to add video track"); return false; } if (!media_stream->AddTrack(audio_track)) { UMBO_WARN("Fail to add audio track"); return false; } } if (!peer_connection->AddStream(media_stream)) { UMBO_WARN("Fail to add media stream to PeerConnection"); return false; } return true; }