~ubuntu-branches/ubuntu/karmic/gnash/karmic

« back to all changes in this revision

Viewing changes to cygnal/cgi-bin/oflaDemo/oflaDemo.h

  • Committer: Bazaar Package Importer
  • Author(s): Sindhudweep Narayan Sarkar
  • Date: 2009-10-07 00:06:10 UTC
  • mfrom: (1.1.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20091007000610-mj9rwqe774gizn1j
Tags: 0.8.6-0ubuntu1
new upstream release 0.8.6 (LP: #435897)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Red5 server side support for the oflaDemo_test via RTMP
 
2
// 
 
3
//   Copyright (C) 2008, 2009 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 _FITCDEMO_H_
 
20
#define _FITCDEMO_H_
 
21
 
 
22
#include <string>
 
23
#include <map>
 
24
#include <vector>
 
25
#include <boost/shared_ptr.hpp>
 
26
#include <boost/shared_array.hpp>
 
27
#include <boost/scoped_array.hpp>
 
28
#include <sstream>
 
29
 
 
30
// gnash headers
 
31
#include "amf.h"
 
32
#include "buffer.h"
 
33
#include "element.h"
 
34
#include "http.h"
 
35
#include "cygnal.h"
 
36
 
 
37
// cygnal headers
 
38
#include "rtmp_server.h"
 
39
 
 
40
namespace cygnal
 
41
{
 
42
 
 
43
    /// \var class demoService
 
44
    ///    This class support the Red5 server functions used by some
 
45
    ///    of their demos.
 
46
class demoService {
 
47
public:
 
48
 
 
49
    typedef struct {
 
50
        std::string name;
 
51
        std::string last;
 
52
        std::string size;
 
53
    } filestats_t ;
 
54
    demoService();
 
55
    ~demoService();
 
56
 
 
57
    /// return the list of FLV files we've found
 
58
    std::vector<boost::shared_ptr<filestats_t> > &getListOfAvailableFiles(const std::string &path);
 
59
 
 
60
    /// return the list of FLV files we've found of the specified type
 
61
    std::vector<boost::shared_ptr<filestats_t> > &getListOfAvailableFiles(const std::string &path,
 
62
                                                                          const std::string &type);
 
63
    std::vector<boost::shared_ptr<filestats_t> > &getFileStats() { return _stats; };
 
64
    
 
65
private:
 
66
    std::string                         _path;
 
67
    std::vector<boost::shared_ptr<filestats_t> >        _stats;
 
68
};
 
69
    
 
70
class OflaDemoTest : public cygnal::RTMPServer
 
71
{
 
72
public:
 
73
    OflaDemoTest ();
 
74
    ~OflaDemoTest ();
 
75
  
 
76
    // Parse an OflaDemo Request message coming from the Red5 oflaDemo_test.
 
77
    std::vector<boost::shared_ptr<amf::Element > > parseOflaDemoRequest(amf::Buffer &buf)
 
78
        { return parseOflaDemoRequest(buf.reference(), buf.size()); };
 
79
    std::vector<boost::shared_ptr<amf::Element > > parseOflaDemoRequest(boost::uint8_t *buf, size_t size);
 
80
    
 
81
    // format a response to the 'oflaDemo' test used for testing Gnash.
 
82
    boost::shared_ptr<amf::Buffer> formatOflaDemoResponse(double num, amf::Element &el);
 
83
    boost::shared_ptr<amf::Buffer> formatOflaDemoResponse(double num, amf::Buffer &data);
 
84
    boost::shared_ptr<amf::Buffer> formatOflaDemoResponse(double num, boost::uint8_t *data, size_t size);
 
85
 
 
86
    boost::shared_ptr<amf::Buffer> getResponse() { return _response; };
 
87
    void setResponse(boost::shared_ptr<amf::Buffer> &x) { _response = x; };
 
88
    
 
89
    void setNetConnection(gnash::RTMPMsg *msg) { _netconnect.reset(msg); };
 
90
    void setNetConnection(boost::shared_ptr<gnash::RTMPMsg> msg) { _netconnect = msg; };
 
91
    boost::shared_ptr<gnash::RTMPMsg> getNetConnection() { return _netconnect;};
 
92
 
 
93
    /// \var _netconnect
 
94
    ///    This store the data from the NetConnection ActionScript
 
95
    ///    object we get as the final part of the handshake process
 
96
    ///    that is used to set up the connection. This has all the
 
97
    ///    file paths and other information needed by the server.
 
98
    boost::shared_ptr<gnash::RTMPMsg>   _netconnect;
 
99
private:
 
100
    boost::shared_ptr<amf::Buffer> _response;
 
101
    boost::shared_ptr<Handler::cygnal_init_t> _info;
 
102
}; 
 
103
 
 
104
// the standard API
 
105
extern "C" {
 
106
    boost::shared_ptr<Handler::cygnal_init_t>oflaDemo_init_func(boost::shared_ptr<gnash::RTMPMsg> &msg);
 
107
    
 
108
    boost::shared_ptr<amf::Buffer> oflaDemo_read_func();
 
109
    size_t oflaDemo_write_func(boost::uint8_t *data, size_t size);
 
110
}
 
111
 
 
112
} // end of cygnal namespace
 
113
#endif  // end of __FITCDEMO_H__
 
114
 
 
115
// local Variables:
 
116
// mode: C++
 
117
// indent-tabs-mode: t
 
118
// End: