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

Side by Side Diff: webrtc/examples/unityplugin/simple_peer_connection.h

Issue 2823783002: An example of Unity native plugin of webrtc for Windows OS (Closed)
Patch Set: Created 3 years, 8 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
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #ifndef WEBRTC_EXAMPLES_UNITYPLUGIN_SIMPLE_PEER_CONNECTION_H_
12 #define WEBRTC_EXAMPLES_UNITYPLUGIN_SIMPLE_PEER_CONNECTION_H_
13
14 #include <map>
15 #include <memory>
16 #include <string>
17 #include <vector>
18
19 #include "webrtc/api/datachannelinterface.h"
20 #include "webrtc/api/mediastreaminterface.h"
21 #include "webrtc/api/peerconnectioninterface.h"
22 #include "webrtc/examples/unityplugin/unity_plugin_apis.h"
23
24 class Conductor : public webrtc::PeerConnectionObserver,
lliuu 2017/04/24 17:25:32 Can we call this SimplePeerConnection instead? Con
GeorgeZ 2017/04/24 22:57:35 I modify the class name as you suggested. Conducto
25 public webrtc::CreateSessionDescriptionObserver,
26 public webrtc::DataChannelObserver,
27 public webrtc::AudioTrackSinkInterface {
28 public:
29 Conductor() {}
30 ~Conductor() {}
31
32 bool InitializePeerConnection(bool is_receiver);
33 void DeletePeerConnection();
34 void AddStreams(bool audio_only);
35 bool CreateDataChannel();
36 bool CreateOffer();
37 bool CreateAnswer();
38 bool SendDataViaDataChannel(const std::string& data);
39 void SetAudioControl(bool is_mute, bool is_record);
40
41 // Register callback functions.
42 void RegisterOnVideoFramReady(VIDEOFRAMEREADY_CALLBACK callback);
43 void RegisterOnLocalDataChannelReady(LOCALDATACHANNELREADY_CALLBACK callback);
44 void RegisterOnDataFromDataChannelReady(
45 DATAFROMEDATECHANNELREADY_CALLBACK callback);
46 void RegisterOnFailure(FAILURE_CALLBACK callback);
47 void RegisterOnAudioBusReady(AUDIOBUSREADY_CALLBACK callback);
48 void RegisterOnLocalSdpReadytoSend(LOCALSDPREADYTOSEND_CALLBACK callback);
49 void RegisterOnIceCandiateReadytoSend(
50 ICECANDIDATEREADYTOSEND_CALLBACK callback);
51 bool ReceivedSdp(const char* sdp);
52 bool ReceivedIceCandidate(const char* ice_candidate);
53
54 bool SetHeadPosition(float x, float y, float z);
55 bool SetHeadRotation(float rx, float ry, float rz, float rw);
56 bool SetRemoteAudioPosition(float x, float y, float z);
57 bool SetRemoteAudioRotation(float rx, float ry, float rz, float rw);
58
59 protected:
60 bool CreatePeerConnection(bool receiver);
61 void CloseDataChannel();
62 std::unique_ptr<cricket::VideoCapturer> OpenVideoCaptureDevice();
63 void SetAudioControl();
64
65 // PeerConnectionObserver implementation.
66 void OnSignalingChange(
67 webrtc::PeerConnectionInterface::SignalingState new_state) override {}
68 void OnAddStream(
69 rtc::scoped_refptr<webrtc::MediaStreamInterface> stream) override;
70 void OnRemoveStream(
71 rtc::scoped_refptr<webrtc::MediaStreamInterface> stream) override {}
72 void OnDataChannel(
73 rtc::scoped_refptr<webrtc::DataChannelInterface> channel) override;
74 void OnRenegotiationNeeded() override {}
75 void OnIceConnectionChange(
76 webrtc::PeerConnectionInterface::IceConnectionState new_state) override {}
77 void OnIceGatheringChange(
78 webrtc::PeerConnectionInterface::IceGatheringState new_state) override {}
79 void OnIceCandidate(const webrtc::IceCandidateInterface* candidate) override;
80 void OnIceConnectionReceivingChange(bool receiving) override {}
81
82 // CreateSessionDescriptionObserver implementation.
83 void OnSuccess(webrtc::SessionDescriptionInterface* desc) override;
84 void OnFailure(const std::string& error) override;
85
86 // DataChannelObserver implementation.
87 void OnStateChange() override;
88 void OnMessage(const webrtc::DataBuffer& buffer) override;
89
90 // AudioTrackSinkInterface implementation.
91 void OnData(const void* audio_data,
92 int bits_per_sample,
93 int sample_rate,
94 size_t number_of_channels,
95 size_t number_of_frames) override;
96
97 // Get remote audio tracks ssrcs.
98 std::vector<uint32_t> GetRemoteAudioTrackSsrcs();
99
100 private:
101 rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_;
102 rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel_;
103 std::map<std::string, rtc::scoped_refptr<webrtc::MediaStreamInterface> >
104 active_streams_;
105
106 webrtc::MediaStreamInterface* remote_stream_ = nullptr;
107
108 VIDEOFRAMEREADY_CALLBACK OnVideoFrameReady = nullptr;
109 LOCALDATACHANNELREADY_CALLBACK OnLocalDataChannelReady = nullptr;
110 DATAFROMEDATECHANNELREADY_CALLBACK OnDataFromDataChannelReady = nullptr;
111 FAILURE_CALLBACK OnFailureMessage = nullptr;
112 AUDIOBUSREADY_CALLBACK OnAudioReady = nullptr;
113
114 LOCALSDPREADYTOSEND_CALLBACK OnLocalSdpReady = nullptr;
115 ICECANDIDATEREADYTOSEND_CALLBACK OnIceCandiateReady = nullptr;
116
117 bool is_mute_audio_ = false;
118 bool is_record_audio_ = false;
119
120 // disallow copy-and-assign
121 Conductor(const Conductor&) = delete;
122 Conductor& operator=(const Conductor&) = delete;
123 };
124
125 #endif // WEBRTC_EXAMPLES_UNITYPLUGIN_SIMPLE_PEER_CONNECTION_H_
OLDNEW
« no previous file with comments | « webrtc/examples/unityplugin/README ('k') | webrtc/examples/unityplugin/simple_peer_connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698