10e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org/* 20e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * libjingle 30e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * Copyright 2010 Google Inc. 40e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * 50e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * Redistribution and use in source and binary forms, with or without 60e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * modification, are permitted provided that the following conditions are met: 70e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * 80e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * 1. Redistributions of source code must retain the above copyright notice, 90e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * this list of conditions and the following disclaimer. 100e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * 2. Redistributions in binary form must reproduce the above copyright notice, 110e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * this list of conditions and the following disclaimer in the documentation 120e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * and/or other materials provided with the distribution. 130e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * 3. The name of the author may not be used to endorse or promote products 140e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * derived from this software without specific prior written permission. 150e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * 160e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 170e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 180e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 190e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 200e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 210e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 220e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 230e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 240e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 250e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 260e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org */ 270e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 280e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#ifndef TALK_SESSION_MEDIA_MEDIARECORDER_H_ 290e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#define TALK_SESSION_MEDIA_MEDIARECORDER_H_ 300e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 310e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#include <map> 320e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#include <string> 330e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 34cf81adffe15fa8ea0f333432e41f6d504148f18abuildbot@webrtc.org#include "talk/session/media/channel.h" 35cf81adffe15fa8ea0f333432e41f6d504148f18abuildbot@webrtc.org#include "talk/session/media/mediasink.h" 362a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org#include "webrtc/base/criticalsection.h" 372a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org#include "webrtc/base/scoped_ptr.h" 382a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org#include "webrtc/base/sigslot.h" 390e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 402a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.orgnamespace rtc { 410e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgclass Pathname; 420e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgclass FileStream; 430e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org} 440e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 450e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgnamespace cricket { 460e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 470e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgclass BaseChannel; 480e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgclass VideoChannel; 490e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgclass VoiceChannel; 500e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgclass RtpDumpWriter; 510e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 520e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// RtpDumpSink implements MediaSinkInterface by dumping the RTP/RTCP packets to 530e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// a file. 540e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgclass RtpDumpSink : public MediaSinkInterface, public sigslot::has_slots<> { 550e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org public: 560e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Takes ownership of stream. 572a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org explicit RtpDumpSink(rtc::StreamInterface* stream); 580e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual ~RtpDumpSink(); 590e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 600e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual void SetMaxSize(size_t size); 610e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual bool Enable(bool enable); 620e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual bool IsEnabled() const { return recording_; } 630e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual void OnPacket(const void* data, size_t size, bool rtcp); 640e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual void set_packet_filter(int filter); 650e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org int packet_filter() const { return packet_filter_; } 660e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org void Flush(); 670e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 680e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org private: 690e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org size_t max_size_; 700e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org bool recording_; 710e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org int packet_filter_; 722a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org rtc::scoped_ptr<rtc::StreamInterface> stream_; 732a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org rtc::scoped_ptr<RtpDumpWriter> writer_; 742a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org rtc::CriticalSection critical_section_; 750e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 760e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org DISALLOW_COPY_AND_ASSIGN(RtpDumpSink); 770e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org}; 780e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 790e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgclass MediaRecorder { 800e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org public: 810e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org MediaRecorder(); 820e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual ~MediaRecorder(); 830e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 840e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org bool AddChannel(VoiceChannel* channel, 852a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org rtc::StreamInterface* send_stream, 862a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org rtc::StreamInterface* recv_stream, 870e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org int filter); 880e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org bool AddChannel(VideoChannel* channel, 892a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org rtc::StreamInterface* send_stream, 902a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org rtc::StreamInterface* recv_stream, 910e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org int filter); 920e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org void RemoveChannel(BaseChannel* channel, SinkType type); 930e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org bool EnableChannel(BaseChannel* channel, bool enable_send, bool enable_recv, 940e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org SinkType type); 950e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org void FlushSinks(); 960e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 970e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org private: 980e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org struct SinkPair { 990e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org bool video_channel; 1000e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org int filter; 1012a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org rtc::scoped_ptr<RtpDumpSink> send_sink; 1022a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org rtc::scoped_ptr<RtpDumpSink> recv_sink; 1030e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org }; 1040e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1050e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org bool InternalAddChannel(BaseChannel* channel, 1060e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org bool video_channel, 1072a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org rtc::StreamInterface* send_stream, 1082a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org rtc::StreamInterface* recv_stream, 1090e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org int filter); 1100e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1110e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org std::map<BaseChannel*, SinkPair*> sinks_; 1122a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org rtc::CriticalSection critical_section_; 1130e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1140e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org DISALLOW_COPY_AND_ASSIGN(MediaRecorder); 1150e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org}; 1160e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1170e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org} // namespace cricket 1180e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1190e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#endif // TALK_SESSION_MEDIA_MEDIARECORDER_H_ 120