- add sources.
[platform/framework/web/crosswalk.git] / src / content / renderer / media / peer_connection_handler_base.h
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_RENDERER_MEDIA_PEER_CONNECTION_HANDLER_BASE_H_
6 #define CONTENT_RENDERER_MEDIA_PEER_CONNECTION_HANDLER_BASE_H_
7
8 #include <map>
9 #include <string>
10
11 #include "base/memory/ref_counted.h"
12 #include "base/message_loop/message_loop_proxy.h"
13 #include "content/common/content_export.h"
14 #include "third_party/WebKit/public/platform/WebMediaStream.h"
15 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h"
16 #include "third_party/libjingle/source/talk/app/webrtc/mediastream.h"
17 #include "third_party/libjingle/source/talk/app/webrtc/peerconnectioninterface.h"
18
19 namespace content {
20 class MediaStreamDependencyFactory;
21 class RemoteMediaStreamImpl;
22
23 // PeerConnectionHandlerBase is the base class of a delegate for the
24 // PeerConnection API messages going between WebKit and native
25 // PeerConnection in libjingle.
26 class CONTENT_EXPORT PeerConnectionHandlerBase
27     : NON_EXPORTED_BASE(public webrtc::PeerConnectionObserver) {
28  public:
29   PeerConnectionHandlerBase(
30       MediaStreamDependencyFactory* dependency_factory);
31
32  protected:
33   virtual ~PeerConnectionHandlerBase();
34
35   void AddStream(const WebKit::WebMediaStream& stream);
36   bool AddStream(const WebKit::WebMediaStream& stream,
37                  const webrtc::MediaConstraintsInterface* constraints);
38   void RemoveStream(const WebKit::WebMediaStream& stream);
39
40   // dependency_factory_ is a raw pointer, and is valid for the lifetime of
41   // MediaStreamImpl.
42   MediaStreamDependencyFactory* dependency_factory_;
43
44   // native_peer_connection_ is the native PeerConnection object,
45   // it handles the ICE processing and media engine.
46   scoped_refptr<webrtc::PeerConnectionInterface> native_peer_connection_;
47
48   typedef std::map<webrtc::MediaStreamInterface*,
49       content::RemoteMediaStreamImpl*> RemoteStreamMap;
50   RemoteStreamMap remote_streams_;
51
52   // The message loop we are created on and on which to make calls to WebKit.
53   // This should be the render thread message loop.
54   scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
55
56   DISALLOW_COPY_AND_ASSIGN(PeerConnectionHandlerBase);
57 };
58
59 }  // namespace content
60
61 #endif  // CONTENT_RENDERER_MEDIA_PEER_CONNECTION_HANDLER_BASE_H_