1 /* 2 * Copyright (C) 2011 Raphael Coeffic 3 * 4 * This file is part of SEMS, a free SIP media server. 5 * 6 * SEMS is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. This program is released under 10 * the GPL with the additional exemption that compiling, linking, 11 * and/or using OpenSSL is allowed. 12 * 13 * For a license to use the SEMS software under conditions 14 * other than those described here, or to purchase support for this 15 * software, please contact iptel.org by e-mail at the following addresses: 16 * info@iptel.org 17 * 18 * SEMS is distributed in the hope that it will be useful, 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 * GNU General Public License for more details. 22 * 23 * You should have received a copy of the GNU General Public License 24 * along with this program; if not, write to the Free Software 25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 26 */ 27 28 #ifndef _RtmpSession_h_ 29 #define _RtmpSession_h_ 30 31 #include "Rtmp.h" 32 #include "AmSession.h" 33 34 #include "librtmp/rtmp.h" 35 36 class RtmpSessionEvent 37 : public AmEvent 38 { 39 public: 40 enum EvType { 41 Disconnect, 42 Accept 43 }; 44 RtmpSessionEvent(EvType t)45 RtmpSessionEvent(EvType t) 46 : AmEvent((int)t) {} 47 getEvType()48 EvType getEvType() { return (EvType)event_id; } 49 }; 50 51 class RtmpAudio; 52 class RtmpConnection; 53 54 class RtmpSession 55 : public AmSession 56 { 57 RtmpAudio* rtmp_audio; 58 59 RtmpConnection* rtmp_connection; 60 AmMutex m_rtmp_conn; 61 62 private: 63 void sendCallState(); 64 void clearConnection(); 65 66 public: 67 RtmpSession(RtmpConnection* c); 68 ~RtmpSession(); 69 70 // @see AmSession 71 void onSessionStart(); 72 void onBye(const AmSipRequest& req); 73 void onBeforeDestroy(); 74 void onSipReply(const AmSipRequest& req, 75 const AmSipReply& reply, 76 AmBasicSipDialog::Status old_dlg_status); 77 78 void onInvite(const AmSipRequest& req); 79 80 // @see AmEventHandler 81 void process(AmEvent*); 82 83 // forwards the packet the RtmpAudio 84 void bufferPacket(const RTMPPacket& p); 85 86 // sets the connection pointer 87 void setConnectionPtr(RtmpConnection* c); 88 89 // sets the outgoing stream ID for RTMP audio packets 90 void setPlayStreamID(unsigned int stream_id); 91 92 // Sends the disconnect event to the session to terminate it 93 void disconnect(); 94 95 // Sends the accept event to the session 96 void accept(); 97 }; 98 99 #endif 100