Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / renderer / media / cast_session.h
blob096977017ed8533e95ca111d1c73941d77fd7cfb
1 // Copyright 2013 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.
5 #ifndef CHROME_RENDERER_MEDIA_CAST_SESSION_H_
6 #define CHROME_RENDERER_MEDIA_CAST_SESSION_H_
8 #include <vector>
10 #include "base/basictypes.h"
11 #include "base/callback.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "net/base/ip_endpoint.h"
16 namespace base {
17 class MessageLoopProxy;
18 } // namespace base
20 namespace media {
21 class VideoFrame;
22 namespace cast {
23 class FrameInput;
24 struct AudioSenderConfig;
25 struct VideoSenderConfig;
26 } // namespace cast
27 } // namespace media
29 namespace content{
30 class P2PSocketClient;
31 } // namespace content
33 class CastSessionDelegate;
35 // This class represents a Cast session and allows the session to be
36 // configured on the main thread. Actual work is forwarded to
37 // CastSessionDelegate on the IO thread.
38 class CastSession : public base::RefCounted<CastSession> {
39 public:
40 typedef
41 base::Callback<void(const scoped_refptr<media::cast::FrameInput>&)>
42 FrameInputAvailableCallback;
43 typedef base::Callback<void(const std::vector<char>&)> SendPacketCallback;
45 CastSession();
47 // Start encoding of audio and video using the provided configuration.
49 // When Cast sender is started and ready to be used
50 // media::cast::FrameInput will be given through the callback. The
51 // callback will be made on the main thread.
52 void StartAudio(const media::cast::AudioSenderConfig& config,
53 const FrameInputAvailableCallback& callback);
54 void StartVideo(const media::cast::VideoSenderConfig& config,
55 const FrameInputAvailableCallback& callback);
57 // Start sending packets using SendPacketCallback. Invoke the callback
58 // with a packet on the render thread. The packet will then be sent out
59 // via network.
60 void StartSending(const SendPacketCallback& callback);
61 void ReceivePacket(const std::vector<char>& packet);
63 private:
64 friend class base::RefCounted<CastSession>;
65 virtual ~CastSession();
67 // This member should never be dereferenced on the main thread.
68 // CastSessionDelegate lives only on the IO thread. It is always
69 // safe to post task on the IO thread to access CastSessionDelegate
70 // because it is owned by this object.
71 scoped_ptr<CastSessionDelegate> delegate_;
73 // Proxy to the IO message loop.
74 const scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_;
76 DISALLOW_COPY_AND_ASSIGN(CastSession);
79 #endif // CHROME_RENDERER_MEDIA_CAST_SESSION_H_