1 //
2 //   Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012
3 //   Free Software Foundation, Inc
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18 
19 #ifndef _RTMPMSG_H_
20 #define _RTMPMSG_H_
21 
22 #include <cstdint>
23 #include <string>
24 #include <vector>
25 
26 #include "amf.h"
27 #include "rtmp.h"
28 #include "element.h"
29 #include "network.h"
30 #include "buffer.h"
31 
32 namespace gnash
33 {
34 
35 class RTMPMsg
36 {
37 public:
38     typedef enum {
39 	APP_GC,
40 	APP_RESOURCE_LOWMEMORY,
41 	APP_SCRIPT_ERROR,
42 	APP_SCRIPT_WARNING,
43 	APP_SHUTDOWN,
44 	NC_CALL_BADVERSION,
45 	NC_CALL_FAILED,
46 	NC_CONNECT_APPSHUTDOWN,
47 	NC_CONNECT_CLOSED,
48 	NC_CONNECT_FAILED,
49 	NC_CONNECT_INVALID_APPLICATION,
50 	NC_CONNECT_REJECTED,
51 	NC_CONNECT_SUCCESS,
52 	NS_CLEAR_FAILED,
53 	NS_CLEAR_SUCCESS,
54 	NS_DATA_START,
55 	NS_FAILED,
56 	NS_INVALID_ARGUMENT,
57 	NS_PAUSE_NOTIFY,
58 	NS_PLAY_COMPLETE,
59 	NS_PLAY_FAILED,
60 	NS_PLAY_FILE_STRUCTURE_INVALID,
61 	NS_PLAY_INSUFFICIENT_BW,
62 	NS_PLAY_NO_SUPPORTED_TRACK_FOUND,
63 	NS_PLAY_PUBLISHNOTIFY,
64 	NS_PLAY_RESET,
65 	NS_PLAY_START,
66 	NS_PLAY_STOP,
67 	NS_PLAY_STREAMNOTFOUND,
68 	NS_PLAY_SWITCH,
69 	NS_PLAY_UNPUBLISHNOTIFY,
70 	NS_PUBLISH_BADNAME,
71 	NS_PUBLISH_START,
72 	NS_RECORD_FAILED,
73 	NS_RECORD_NOACCESS,
74 	NS_RECORD_START,
75 	NS_RECORD_STOP,
76 	NS_SEEK_FAILED,
77 	NS_SEEK_NOTIFY,
78 	NS_UNPAUSE_NOTIFY,
79 	NS_UNPUBLISHED_SUCCESS,
80 	SO_CREATION_FAILED,
81 	SO_NO_READ_ACCESS,
82 	SO_NO_WRITE_ACCESS,
83 	SO_PERSISTENCE_MISMATCH,
84 	// Anything below here is specific to Gnash's implementation
85 	NS_CREATE_STREAM,
86 	NS_DELETE_STREAM
87     } rtmp_status_e;
88     typedef enum {
89 	FROM_CLIENT,			  // SWF player
90 	FROM_SERVER                      // Flash com server
91     } rtmp_source_e;
92     RTMPMsg();
93     ~RTMPMsg();
94 
addObject(std::shared_ptr<cygnal::Element> el)95     void addObject(std::shared_ptr<cygnal::Element> el) { _amfobjs.push_back(el); };
size()96     size_t size() { return _amfobjs.size(); };
getElements()97     std::vector<std::shared_ptr<cygnal::Element> > getElements() { return _amfobjs; };
98 
setMethodName(const std::string & name)99     void setMethodName(const std::string &name) { _method = name; } ;
getMethodName()100     std::string &getMethodName()         { return _method; };
101 
setTransactionID(double num)102     void setTransactionID(double num)         { _transid = num; };
getTransactionID()103     double getTransactionID()	         { return _transid; };
104 
105     rtmp_status_e checkStatus(std::shared_ptr<cygnal::Element> el);
setStatus(rtmp_status_e st)106     void setStatus(rtmp_status_e st)     { _status = st; };
getStatus()107     rtmp_status_e getStatus()	         { return _status; };
108 
setChannel(std::uint8_t num)109     void setChannel(std::uint8_t num) { _channel = num; };
getChannel()110     std::uint8_t getChannel()         { return _channel; } ;
111 
112     std::shared_ptr<cygnal::Element> operator[](size_t x);
at(size_t x)113     std::shared_ptr<cygnal::Element> at(size_t x) { return _amfobjs[x]; };
114 
115     /// \brief Find the named property for this Object.
116     ///
117     /// @param name An ASCII string that is the name of the property to
118     ///		search for.
119     ///
120     /// @return A smart pointer to the Element for this property.
121     DSOEXPORT std::shared_ptr<cygnal::Element> findProperty(const std::string &name);
122 
123 //    void setHeaderData(RTMP::rtmp_head_t &qhead);
124 
125 // Dump internal status to the terminal
126     DSOEXPORT void dump();
127 
128   protected:
129     rtmp_source_e	  _routing;
130     rtmp_status_e	  _status;
131     std::string           _method;
132     double                _transid;
133     std::vector<std::shared_ptr<cygnal::Element> > _amfobjs;
134     std::uint8_t       _channel;
135 };
136 
137 } // end of gnash namespace
138 // end of _RTMPMSG_H_
139 #endif
140 
141 // local Variables:
142 // mode: C++
143 // indent-tabs-mode: t
144 // End:
145 
146