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 _RtmpSender_h_
29 #define _RtmpSender_h_
30 
31 #include "AmThread.h"
32 #include <queue>
33 #include <string>
34 using std::queue;
35 using std::string;
36 
37 #include "librtmp/rtmp.h"
38 
39 class RtmpSender
40   : public AmThread
41 {
42   // sender queue
43   queue<RTMPPacket> q_send;
44   AmMutex           m_q_send;
45   AmCondition<bool> has_work;
46 
47   // ptr to RtmpConnection::rtmp
48   RTMP* p_rtmp;
49 
50   // execution control
51   AmSharedVar<bool> running;
52 
53   int SendChangeChunkSize();
54 
55 protected:
56   void run();
57   void on_stop();
58 
59 public:
60   RtmpSender(RTMP* r);
61   ~RtmpSender();
62 
63   // adds a packet to the sender queue
64   int push_back(const RTMPPacket& p);
65 
66   int SendCtrl(short nType, unsigned int nObject, unsigned int nTime);
67   int SendResultNumber(double txn, double ID);
68   int SendConnectResult(double txn);
69   int SendRegisterResult(double txn, const char* str);
70   int SendErrorResult(double txn, const char* str);
71   int SendPause(int DoPause, int iTime);
72 
73   int SendPlayStart();
74   int SendPlayStop();
75   int SendStreamBegin();
76   int SendStreamEOF();
77 
78   int SendCallStatus(int status);
79   int NotifyIncomingCall(const string& uri);
80 
81 };
82 
83 #endif
84