webrtc源码走读之api

api目录下封装了webrtc相关的供外部调用接口.

datachannel.h
1
2
3
// Including this file is deprecated. It is no longer part of the public API.
// This only includes the file in its new location for backwards compatibility.
#include "webrtc/pc/datachannel.h"
datachannelinterface.h
  • DataChannelObserver:Used to implement RTCDataChannel events.The code responding to these callbacks should unwind the stack before using any other webrtc APIs; re-entrancy is not supported.
  • DataChannelInterface:
dtmfsenderinterface.h
  • DtmfSenderObserverInterface:DtmfSender callback interface, used to implement RTCDtmfSender events.Applications should implement this interface to get notifications from the DtmfSender.
  • DtmfSenderInterface:The interface of native implementation of the RTCDTMFSender defined by the WebRTC W3C Editor’s Draft.
fakemetricsobserver.h/cc
  • FakeMetricsObserver
jsep.h
  • IceCandidateInterface:Class representation of an ICE candidate.An instance of this interface is supposed to be owned by one class at a time and is therefore not expected to be thread safe.An instance can be created by CreateIceCandidate.
  • IceCandidateCollection:This class represents a collection of candidates for a specific m= section.Used in SessionDescriptionInterface.
  • SessionDescriptionInterface:Class representation of an SDP session description.An instance of this interface is supposed to be owned by one class at a time and is therefore not expected to be thread safe.An instance can be created by CreateSessionDescription.
  • CreateSessionDescriptionObserver:CreateOffer and CreateAnswer callback interface.
  • SetSessionDescriptionObserver:SetLocalDescription and SetRemoteDescription callback interface.
jsepicecandidate.h
  • JsepIceCandidate:继承自IceCandidateInterface
  • JsepCandidateCollection:继承自IceCandidateCollection
jsepsessiondescription.h
  • JsepSessionDescription:Implementation of SessionDescriptionInterface.
mediaconstraintsinterface.h/cc
  • MediaConstraintsInterface:Interface used for passing arguments about media constraints to the MediaStream and PeerConnection implementation.Constraints may be either “mandatory”, which means that unless satisfied,the method taking the constraints should fail, or “optional”, which means they may not be satisfied..
mediastream.h
1
2
3
// Including this file is deprecated. It is no longer part of the public API.
// This only includes the file in its new location for backwards compatibility.
#include "webrtc/pc/mediastream.h"
mediastreaminterface.h/cc
  • OberverInterface
  • NotifierInterface
  • MediaSourceInterface:Base class for sources. A MediaStreamTrack has an underlying source that provides media. A source can be shared by multiple tracks.继承自notifierInterface
  • MediaStreamTrackInterface:继承自notifierInterface
  • VideoTrackSourceInterface:VideoTrackSourceInterface is a reference counted source used for VideoTracks. The same source can be used by multiple VideoTracks.继承自MediaSourceinterface与VideoSourceInterface
  • VideoTrackInterface: 继承自MediaStreamTrackInterface与VideoSourceInterface
  • AudioTrackSinkinterface:
  • AudioSourceInterface:AudioSourceInterface is a reference counted source used for AudioTracks.The same source can be used by multiple AudioTracks.继承自MediaSourceInterface.
  • AudioProcessorInterface:Interface of the audio processor used by the audio track to collect statistics.
  • AudioTrackInterface:继承自MediaStreamTrackInterface
  • MediaStreamInterface: A major difference is that remote audio/video tracks (received by a PeerConnection/RtpReceiver) are not synchronized simply by adding them to the same stream; a session description with the correct “a=msid” attributes must be pushed down.Thus, this interface acts as simply a container for tracks.
mediastreamproxy.h

Move this to .cc file and out of api/. What threads methods // are called on is an implementation detail.

mediastreamtrack.h
1
2
3
// Including this file is deprecated. It is no longer part of the public API.
// This only includes the file in its new location for backwards compatibility.
#include "webrtc/pc/mediastreamtrack.h"
mediatypes.h/cc

mediatype到string转换

notifier.h
  • Notifier:
peerconnectionfactoryproxy.h
peerconnectioninterface.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// This file contains the PeerConnection interface as defined in
// http://dev.w3.org/2011/webrtc/editor/webrtc.html#peer-to-peer-connections.
//
// The PeerConnectionFactory class provides factory methods to create
// PeerConnection, MediaStream and MediaStreamTrack objects.
//
// The following steps are needed to setup a typical call using WebRTC:
//
// 1. Create a PeerConnectionFactoryInterface. Check constructors for more
// information about input parameters.
//
// 2. Create a PeerConnection object. Provide a configuration struct which
// points to STUN and/or TURN servers used to generate ICE candidates, and
// provide an object that implements the PeerConnectionObserver interface,
// which is used to receive callbacks from the PeerConnection.
//
// 3. Create local MediaStreamTracks using the PeerConnectionFactory and add
// them to PeerConnection by calling AddTrack (or legacy method, AddStream).
//
// 4. Create an offer, call SetLocalDescription with it, serialize it, and send
// it to the remote peer
//
// 5. Once an ICE candidate has been gathered, the PeerConnection will call the
// observer function OnIceCandidate. The candidates must also be serialized and
// sent to the remote peer.
//
// 6. Once an answer is received from the remote peer, call
// SetRemoteDescription with the remote answer.
//
// 7. Once a remote candidate is received from the remote peer, provide it to
// the PeerConnection by calling AddIceCandidate.
//
// The receiver of a call (assuming the application is "call"-based) can decide
// to accept or reject the call; this decision will be taken by the application,
// not the PeerConnection.
//
// If the application decides to accept the call, it should:
//
// 1. Create PeerConnectionFactoryInterface if it doesn't exist.
//
// 2. Create a new PeerConnection.
//
// 3. Provide the remote offer to the new PeerConnection object by calling
// SetRemoteDescription.
//
// 4. Generate an answer to the remote offer by calling CreateAnswer and send it
// back to the remote peer.
//
// 5. Provide the local answer to the new PeerConnection by calling
// SetLocalDescription with the answer.
//
// 6. Provide the remote ICE candidates by calling AddIceCandidate.
//
// 7. Once a candidate has been gathered, the PeerConnection will call the
// observer function OnIceCandidate. Send these candidates to the remote peer.
  • StreamCollectionInterface
  • StatsObserver
  • PeerConnectionInterface
  • PeerConnectionObserver:PeerConnection callback interface, used for RTCPeerConnection events. Application should implement these methods.
  • PeerConnectionFactoryInterface:PeerConnectionFactoryInterface is the factory interface used for creating PeerConnection, MediaStream and MediaStreamTrack objects.The simplest method for obtaiing one, CreatePeerConnectionFactory will create the required libjingle threads, socket and network manager factory classes for networking if none are provided, though it requires that the application runs a message loop on the thread that called the method (see explanation below) If an application decides to provide its own threads and/or implementation of networking classes, it should use the alternate CreatePeerConnectionFactory method which accepts threads as input, and use the CreatePeerConnection version that takes a PortAllocator as an argument.
peerconnectionproxy.h
proxy.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// This file contains Macros for creating proxies for webrtc MediaStream and
// PeerConnection classes.
// TODO(deadbeef): Move this to pc/; this is part of the implementation.

//
// Example usage:
//
// class TestInterface : public rtc::RefCountInterface {
// public:
// std::string FooA() = 0;
// std::string FooB(bool arg1) const = 0;
// std::string FooC(bool arg1) = 0;
// };
//
// Note that return types can not be a const reference.
//
// class Test : public TestInterface {
// ... implementation of the interface.
// };
//
// BEGIN_PROXY_MAP(Test)
// PROXY_SIGNALING_THREAD_DESTRUCTOR()
// PROXY_METHOD0(std::string, FooA)
// PROXY_CONSTMETHOD1(std::string, FooB, arg1)
// PROXY_WORKER_METHOD1(std::string, FooC, arg1)
// END_PROXY_MAP()
//
// Where the destructor and first two methods are invoked on the signaling
// thread, and the third is invoked on the worker thread.
//
// The proxy can be created using
//
// TestProxy::Create(Thread* signaling_thread, Thread* worker_thread,
// TestInterface*).
//
// The variant defined with BEGIN_SIGNALING_PROXY_MAP is unaware of
// the worker thread, and invokes all methods on the signaling thread.
//
// The variant defined with BEGIN_OWNED_PROXY_MAP does not use
// refcounting, and instead just takes ownership of the object being proxied.
rtcerror.h/cc
rtcerror_unittest.cc
rtpparameters.h
rtpreceiverinterface.h
rtpsender.h
rtpsenderinterface.h
statstypes.h/cc
streamcollection.h
umametrics.h
videosourceproxy.h
videotracksource.h
webrtcsdp.h
audio/audio_mixer.h
  • AudioMixer:This class is under development and is not yet intended for for use outside of WebRtc/Libjingle.
audio_codecs/audio_decoder.h/cc
  • AudioDecoder
audio_codecs/audio_decoder_factory.h
  • AudioDecoderFactory
audio_codecs/audio_encoder.h/cc

-AudioEncoder: his is the interface class for encoders in AudioCoding module. Each codec type must have an implementation of this class.

audio_codecs/audio_encoder_factory.h
  • AudioEncoderFactory
audio_codecs/audio_format.h/cc
audio_codecs/builtin_audio_encoder_factory.h/cc
audio_codecs/builtin_audio_decoder_factory.h/cc
call/audio_sink.h
call/transport.h
ortc/mediadescription.h/cc
ortc/mediadescription_unittest.cc
ortc/ortcfactoryinterface.h
ortc/ortcrtpreceiverinterface.h
ortc/ortcrtpsenderinterface.h
ortc/packettransportinterface.h
ortc/rtptransportcontrollerinterface.h
ortc/rtptransportinterface.h
ortc/sessiondecription.h/cc
ortc/sessiondescription_unittest.cc
ortc/srtptransportinerface.h
ortc/udptransportinterface.h
坚持原创技术分享,您的支持将鼓励我继续创作!