3 * Copyright 2010 Google Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
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.
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.
28 #ifndef TALK_SESSION_MEDIA_MEDIARECORDER_H_
29 #define TALK_SESSION_MEDIA_MEDIARECORDER_H_
34 #include "talk/session/media/channel.h"
35 #include "talk/session/media/mediasink.h"
36 #include "webrtc/base/criticalsection.h"
37 #include "webrtc/base/scoped_ptr.h"
38 #include "webrtc/base/sigslot.h"
52 // RtpDumpSink implements MediaSinkInterface by dumping the RTP/RTCP packets to
54 class RtpDumpSink : public MediaSinkInterface, public sigslot::has_slots<> {
56 // Takes ownership of stream.
57 explicit RtpDumpSink(rtc::StreamInterface* stream);
58 virtual ~RtpDumpSink();
60 virtual void SetMaxSize(size_t size);
61 virtual bool Enable(bool enable);
62 virtual bool IsEnabled() const { return recording_; }
63 virtual void OnPacket(const void* data, size_t size, bool rtcp);
64 virtual void set_packet_filter(int filter);
65 int packet_filter() const { return packet_filter_; }
72 rtc::scoped_ptr<rtc::StreamInterface> stream_;
73 rtc::scoped_ptr<RtpDumpWriter> writer_;
74 rtc::CriticalSection critical_section_;
76 DISALLOW_COPY_AND_ASSIGN(RtpDumpSink);
82 virtual ~MediaRecorder();
84 bool AddChannel(VoiceChannel* channel,
85 rtc::StreamInterface* send_stream,
86 rtc::StreamInterface* recv_stream,
88 bool AddChannel(VideoChannel* channel,
89 rtc::StreamInterface* send_stream,
90 rtc::StreamInterface* recv_stream,
92 void RemoveChannel(BaseChannel* channel, SinkType type);
93 bool EnableChannel(BaseChannel* channel, bool enable_send, bool enable_recv,
101 rtc::scoped_ptr<RtpDumpSink> send_sink;
102 rtc::scoped_ptr<RtpDumpSink> recv_sink;
105 bool InternalAddChannel(BaseChannel* channel,
107 rtc::StreamInterface* send_stream,
108 rtc::StreamInterface* recv_stream,
111 std::map<BaseChannel*, SinkPair*> sinks_;
112 rtc::CriticalSection critical_section_;
114 DISALLOW_COPY_AND_ASSIGN(MediaRecorder);
117 } // namespace cricket
119 #endif // TALK_SESSION_MEDIA_MEDIARECORDER_H_