~ubuntu-branches/ubuntu/precise/crtmpserver/precise-backports

« back to all changes in this revision

Viewing changes to applications/vmapp/src/vm/baseappvirtualmachine.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Andriy Beregovenko, Andriy Beregovenko, Alessio Treglia
  • Date: 2011-06-06 19:41:18 UTC
  • mfrom: (3.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20110606194118-3bmdj5tz10jp571e
[ Andriy Beregovenko ]
* Update debian changelog.
* Imported Upstream version 0.0~dfsg+svn474.
* Update patches relative to new upstream upload.

[ Alessio Treglia ]
* Add script to retrieve sources from upstream's SVN and regenerate the
  tarball.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
 *  Copyright (c) 2010,
 
3
 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com)
 
4
 *
 
5
 *  This file is part of crtmpserver.
 
6
 *  crtmpserver 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 3 of the License, or
 
9
 *  (at your option) any later version.
 
10
 *
 
11
 *  crtmpserver is distributed in the hope that it will be useful,
 
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 *  GNU General Public License for more details.
 
15
 *
 
16
 *  You should have received a copy of the GNU General Public License
 
17
 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>.
 
18
 */
 
19
 
 
20
#include "vm/baseappvirtualmachine.h"
 
21
#include "vm/lua/luaappvirtualmachine.h"
 
22
#include "basevm.h"
 
23
using namespace app_vmapp;
 
24
 
 
25
BaseAppVirtualMachine::BaseAppVirtualMachine() {
 
26
 
 
27
}
 
28
 
 
29
BaseAppVirtualMachine *BaseAppVirtualMachine::GetVM(string type, string script,
 
30
                BaseClientApplication *pApplication) {
 
31
        BaseAppVirtualMachine *pResult = NULL;
 
32
 
 
33
        //1. Instantiate the VM
 
34
        if (false) {
 
35
 
 
36
        }
 
37
#ifdef HAS_LUA
 
38
        else if (type == "lua") {
 
39
                pResult = new LuaAppVirtualMachine();
 
40
                pResult->_pApplication = pApplication;
 
41
        }
 
42
#endif /* HAS_LUA */
 
43
        if (pResult == NULL) {
 
44
                FATAL("No machine with type %s available", STR(type));
 
45
                return NULL;
 
46
        }
 
47
 
 
48
        //2. Bind the API
 
49
        if (!pResult->BindAPI()) {
 
50
                FATAL("Unable to bind API");
 
51
                delete pResult;
 
52
                return NULL;
 
53
        }
 
54
 
 
55
        //3. Initialize the virtual machine
 
56
        if (!pResult->Initialize(script)) {
 
57
                FATAL("Unable to initialize virtual machine with script %s", STR(script));
 
58
                delete pResult;
 
59
                return NULL;
 
60
        }
 
61
 
 
62
        //3. Done :)
 
63
        return pResult;
 
64
}
 
65
 
 
66
BaseAppVirtualMachine::~BaseAppVirtualMachine() {
 
67
 
 
68
}