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

Side by Side Diff: webrtc/examples/peerconnection/client/conductor.cc

Issue 2083903003: Tried to reproduce the issue with AudioTrackSinkInterface::OnData (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2012 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/examples/peerconnection/client/conductor.h" 11 #include "webrtc/examples/peerconnection/client/conductor.h"
12 12
13 #include <iostream>
13 #include <memory> 14 #include <memory>
14 #include <utility> 15 #include <utility>
15 #include <vector> 16 #include <vector>
16 17
17 #include "webrtc/api/test/fakeconstraints.h" 18 #include "webrtc/api/test/fakeconstraints.h"
18 #include "webrtc/base/common.h" 19 #include "webrtc/base/common.h"
19 #include "webrtc/base/json.h" 20 #include "webrtc/base/json.h"
20 #include "webrtc/base/logging.h" 21 #include "webrtc/base/logging.h"
21 #include "webrtc/examples/peerconnection/client/defaults.h" 22 #include "webrtc/examples/peerconnection/client/defaults.h"
22 #include "webrtc/media/engine/webrtcvideocapturerfactory.h" 23 #include "webrtc/media/engine/webrtcvideocapturerfactory.h"
23 #include "webrtc/modules/video_capture/video_capture_factory.h" 24 #include "webrtc/modules/video_capture/video_capture_factory.h"
24 25
25 // Names used for a IceCandidate JSON object. 26 // Names used for a IceCandidate JSON object.
26 const char kCandidateSdpMidName[] = "sdpMid"; 27 const char kCandidateSdpMidName[] = "sdpMid";
27 const char kCandidateSdpMlineIndexName[] = "sdpMLineIndex"; 28 const char kCandidateSdpMlineIndexName[] = "sdpMLineIndex";
28 const char kCandidateSdpName[] = "candidate"; 29 const char kCandidateSdpName[] = "candidate";
29 30
30 // Names used for a SessionDescription JSON object. 31 // Names used for a SessionDescription JSON object.
31 const char kSessionDescriptionTypeName[] = "type"; 32 const char kSessionDescriptionTypeName[] = "type";
32 const char kSessionDescriptionSdpName[] = "sdp"; 33 const char kSessionDescriptionSdpName[] = "sdp";
33 34
34 #define DTLS_ON true 35 #define DTLS_ON true
35 #define DTLS_OFF false 36 #define DTLS_OFF false
36 37
38 class MyAudioSink : public webrtc::AudioTrackSinkInterface {
39 public:
40 MyAudioSink() { std::cout << "[Sink] Constructing new sink!" << std::endl; }
41 void OnData(const void* audio_data,
42 int bits_per_sample,
43 int sample_rate,
44 size_t number_of_channels,
45 size_t number_of_frames) {
46 std::cout << "[Sink] bits per sample: " << bits_per_sample << "\n"
47 << "[Sink] sample rate: " << sample_rate << "\n"
48 << "[Sink] #channels: " << number_of_channels << "\n"
49 << "[Sink] #frames: " << number_of_frames
50 << std::endl;
51 }
52 };
53
37 class DummySetSessionDescriptionObserver 54 class DummySetSessionDescriptionObserver
38 : public webrtc::SetSessionDescriptionObserver { 55 : public webrtc::SetSessionDescriptionObserver {
39 public: 56 public:
40 static DummySetSessionDescriptionObserver* Create() { 57 static DummySetSessionDescriptionObserver* Create() {
41 return 58 return
42 new rtc::RefCountedObject<DummySetSessionDescriptionObserver>(); 59 new rtc::RefCountedObject<DummySetSessionDescriptionObserver>();
43 } 60 }
44 virtual void OnSuccess() { 61 virtual void OnSuccess() {
45 LOG(INFO) << __FUNCTION__; 62 LOG(INFO) << __FUNCTION__;
46 } 63 }
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 case NEW_STREAM_ADDED: { 503 case NEW_STREAM_ADDED: {
487 webrtc::MediaStreamInterface* stream = 504 webrtc::MediaStreamInterface* stream =
488 reinterpret_cast<webrtc::MediaStreamInterface*>( 505 reinterpret_cast<webrtc::MediaStreamInterface*>(
489 data); 506 data);
490 webrtc::VideoTrackVector tracks = stream->GetVideoTracks(); 507 webrtc::VideoTrackVector tracks = stream->GetVideoTracks();
491 // Only render the first track. 508 // Only render the first track.
492 if (!tracks.empty()) { 509 if (!tracks.empty()) {
493 webrtc::VideoTrackInterface* track = tracks[0]; 510 webrtc::VideoTrackInterface* track = tracks[0];
494 main_wnd_->StartRemoteRenderer(track); 511 main_wnd_->StartRemoteRenderer(track);
495 } 512 }
513
514 webrtc::AudioTrackVector audio_tracks = stream->GetAudioTracks();
515 for (auto & audio_track : audio_tracks) {
516 audio_track->AddSink(new MyAudioSink());
517 }
518
496 stream->Release(); 519 stream->Release();
497 break; 520 break;
498 } 521 }
499 522
500 case STREAM_REMOVED: { 523 case STREAM_REMOVED: {
501 // Remote peer stopped sending a stream. 524 // Remote peer stopped sending a stream.
502 webrtc::MediaStreamInterface* stream = 525 webrtc::MediaStreamInterface* stream =
503 reinterpret_cast<webrtc::MediaStreamInterface*>( 526 reinterpret_cast<webrtc::MediaStreamInterface*>(
504 data); 527 data);
505 stream->Release(); 528 stream->Release();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 } 560 }
538 561
539 void Conductor::OnFailure(const std::string& error) { 562 void Conductor::OnFailure(const std::string& error) {
540 LOG(LERROR) << error; 563 LOG(LERROR) << error;
541 } 564 }
542 565
543 void Conductor::SendMessage(const std::string& json_object) { 566 void Conductor::SendMessage(const std::string& json_object) {
544 std::string* msg = new std::string(json_object); 567 std::string* msg = new std::string(json_object);
545 main_wnd_->QueueUIThreadCallback(SEND_MESSAGE_TO_PEER, msg); 568 main_wnd_->QueueUIThreadCallback(SEND_MESSAGE_TO_PEER, msg);
546 } 569 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698