~ubuntu-branches/debian/experimental/kopete/experimental

« back to all changes in this revision

Viewing changes to protocols/jabber/googletalk/libjingle/talk/app/webrtc/peerconnectionimpl.h

  • Committer: Package Import Robot
  • Author(s): Maximiliano Curia
  • Date: 2015-02-24 11:32:57 UTC
  • mfrom: (1.1.41 vivid)
  • Revision ID: package-import@ubuntu.com-20150224113257-gnupg4v7lzz18ij0
Tags: 4:14.12.2-1
* New upstream release (14.12.2).
* Bump Standards-Version to 3.9.6, no changes needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * libjingle
3
 
 * Copyright 2011, Google Inc.
4
 
 *
5
 
 * Redistribution and use in source and binary forms, with or without
6
 
 * modification, are permitted provided that the following conditions are met:
7
 
 *
8
 
 *  1. Redistributions of source code must retain the above copyright notice,
9
 
 *     this list of conditions and the following disclaimer.
10
 
 *  2. Redistributions in binary form must reproduce the above copyright notice,
11
 
 *     this list of conditions and the following disclaimer in the documentation
12
 
 *     and/or other materials provided with the distribution.
13
 
 *  3. The name of the author may not be used to endorse or promote products
14
 
 *     derived from this software without specific prior written permission.
15
 
 *
16
 
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17
 
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18
 
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19
 
 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20
 
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21
 
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22
 
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23
 
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24
 
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25
 
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 
 */
27
 
 
28
 
#ifndef TALK_APP_WEBRTC_PEERCONNECTIONIMPL_H_
29
 
#define TALK_APP_WEBRTC_PEERCONNECTIONIMPL_H_
30
 
 
31
 
#include <map>
32
 
#include <string>
33
 
 
34
 
#include "talk/app/webrtc/mediastreamsignaling.h"
35
 
#include "talk/app/webrtc/peerconnection.h"
36
 
#include "talk/app/webrtc/peerconnectionfactoryimpl.h"
37
 
#include "talk/app/webrtc/roapsignaling.h"
38
 
#include "talk/app/webrtc/streamcollectionimpl.h"
39
 
#include "talk/app/webrtc/webrtcsession.h"
40
 
#include "talk/base/scoped_ptr.h"
41
 
#include "talk/p2p/client/httpportallocator.h"
42
 
 
43
 
namespace webrtc {
44
 
class MediaStreamHandlers;
45
 
 
46
 
// PeerConnectionImpl implements the PeerConnection interface.
47
 
// It uses RoapSignaling and WebRtcSession to implement
48
 
// the PeerConnection functionality.
49
 
class PeerConnection : public PeerConnectionInterface,
50
 
                       public RemoteMediaStreamObserver,
51
 
                       public talk_base::MessageHandler,
52
 
                       public sigslot::has_slots<> {
53
 
 public:
54
 
  explicit PeerConnection(PeerConnectionFactory* factory);
55
 
 
56
 
  bool Initialize(bool use_roap,
57
 
                  const std::string& configuration,
58
 
                  PeerConnectionObserver* observer);
59
 
 
60
 
  virtual ~PeerConnection();
61
 
 
62
 
  virtual void ProcessSignalingMessage(const std::string& msg);
63
 
  virtual bool Send(const std::string& msg) {
64
 
    // TODO: implement
65
 
    ASSERT(false);
66
 
    return false;
67
 
  }
68
 
  virtual talk_base::scoped_refptr<StreamCollectionInterface> local_streams();
69
 
  virtual talk_base::scoped_refptr<StreamCollectionInterface> remote_streams();
70
 
  virtual void AddStream(LocalMediaStreamInterface* stream);
71
 
  virtual void RemoveStream(LocalMediaStreamInterface* stream);
72
 
  virtual void CommitStreamChanges();
73
 
  virtual void Close();
74
 
  virtual ReadyState ready_state();
75
 
  virtual SdpState sdp_state();
76
 
 
77
 
  // Jsep functions.
78
 
  virtual SessionDescriptionInterface* CreateOffer(const MediaHints& hints);
79
 
  virtual SessionDescriptionInterface* CreateAnswer(
80
 
      const MediaHints& hints,
81
 
      const SessionDescriptionInterface* offer);
82
 
 
83
 
  virtual bool StartIce(IceOptions options);
84
 
  virtual bool SetLocalDescription(Action action,
85
 
                                   SessionDescriptionInterface* desc);
86
 
  virtual bool SetRemoteDescription(Action action,
87
 
                                    SessionDescriptionInterface* desc);
88
 
  virtual bool ProcessIceMessage(const IceCandidateInterface* ice_candidate);
89
 
  virtual const SessionDescriptionInterface* local_description() const;
90
 
  virtual const SessionDescriptionInterface* remote_description() const;
91
 
 
92
 
 private:
93
 
  // Implement talk_base::MessageHandler.
94
 
  void OnMessage(talk_base::Message* msg);
95
 
 
96
 
  // Signals from RoapSignaling.
97
 
  void OnNewPeerConnectionMessage(const std::string& message);
98
 
  void OnSignalingStateChange(RoapSignaling::State state);
99
 
 
100
 
  // Implements RemoteMediaStreamObserver.
101
 
  virtual void OnAddStream(MediaStreamInterface* stream);
102
 
  virtual void OnRemoveStream(MediaStreamInterface* stream);
103
 
 
104
 
  // Signals from WebRtcSession.
105
 
  void OnSessionStateChange(cricket::BaseSession* session,
106
 
                            cricket::BaseSession::State state);
107
 
 
108
 
  void ChangeReadyState(PeerConnectionInterface::ReadyState ready_state);
109
 
  void ChangeSdpState(PeerConnectionInterface::SdpState sdp_state);
110
 
  void Terminate_s();
111
 
 
112
 
  talk_base::Thread* signaling_thread() const {
113
 
    return factory_->signaling_thread();
114
 
  }
115
 
 
116
 
  // Storing the factory as a scoped reference pointer ensures that the memory
117
 
  // in the PeerConnectionFactoryImpl remains available as long as the
118
 
  // PeerConnection is running. It is passed to PeerConnection as a raw pointer.
119
 
  // However, since the reference counting is done in the
120
 
  // PeerConnectionFactoryInteface all instances created using the raw pointer
121
 
  // will refer to the same reference count.
122
 
  talk_base::scoped_refptr<PeerConnectionFactory> factory_;
123
 
  PeerConnectionObserver* observer_;
124
 
  ReadyState ready_state_;
125
 
  SdpState sdp_state_;
126
 
  talk_base::scoped_refptr<StreamCollection> local_media_streams_;
127
 
 
128
 
  talk_base::scoped_ptr<cricket::PortAllocator> port_allocator_;
129
 
  talk_base::scoped_ptr<WebRtcSession> session_;
130
 
  talk_base::scoped_ptr<RoapSignaling> roap_signaling_;
131
 
  talk_base::scoped_ptr<MediaStreamSignaling> mediastream_signaling_;
132
 
  talk_base::scoped_ptr<MediaStreamHandlers> stream_handler_;
133
 
};
134
 
 
135
 
}  // namespace webrtc
136
 
 
137
 
#endif  // TALK_APP_WEBRTC_PEERCONNECTIONIMPL_H_