From c76ddcb7811f95802802d65d56adeaeab5af9a39 Mon Sep 17 00:00:00 2001 From: lilo_booter Date: Sun, 19 Sep 2004 11:49:06 +0000 Subject: [PATCH] Added the response object git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt++@431 d19143bc-622f-0410-bfdd-b5b2a6649095 --- mlt++/src/Makefile | 5 ++-- mlt++/src/Mlt.h | 3 +- mlt++/src/MltMiracle.cpp | 19 +++++++++---- mlt++/src/MltMiracle.h | 5 ++-- mlt++/src/MltResponse.cpp | 59 +++++++++++++++++++++++++++++++++++++++ mlt++/src/MltResponse.h | 43 ++++++++++++++++++++++++++++ mlt++/swig/mltpp.i | 3 ++ 7 files changed, 126 insertions(+), 11 deletions(-) create mode 100644 mlt++/src/MltResponse.cpp create mode 100644 mlt++/src/MltResponse.h diff --git a/mlt++/src/Makefile b/mlt++/src/Makefile index 5f3df886..ea24b279 100644 --- a/mlt++/src/Makefile +++ b/mlt++/src/Makefile @@ -12,14 +12,15 @@ OBJS = MltConsumer.o \ MltFilter.o \ MltFilteredConsumer.o \ MltFrame.o \ + MltMiracle.o \ MltMultitrack.o \ MltPlaylist.o \ MltProducer.o \ MltProperties.o \ + MltResponse.o \ MltService.o \ MltTractor.o \ - MltTransition.o \ - MltMiracle.o + MltTransition.o SRCS = $(OBJS:.o=.cpp) diff --git a/mlt++/src/Mlt.h b/mlt++/src/Mlt.h index 7cb85af8..c5ba6274 100644 --- a/mlt++/src/Mlt.h +++ b/mlt++/src/Mlt.h @@ -28,13 +28,14 @@ #include "MltFilter.h" #include "MltFilteredConsumer.h" #include "MltFrame.h" +#include "MltMiracle.h" #include "MltMultitrack.h" #include "MltPlaylist.h" #include "MltProducer.h" #include "MltProperties.h" +#include "MltResponse.h" #include "MltService.h" #include "MltTractor.h" #include "MltTransition.h" -#include "MltMiracle.h" #endif diff --git a/mlt++/src/MltMiracle.cpp b/mlt++/src/MltMiracle.cpp index ef884496..c7b5fa26 100644 --- a/mlt++/src/MltMiracle.cpp +++ b/mlt++/src/MltMiracle.cpp @@ -20,6 +20,7 @@ #include "MltMiracle.h" #include "MltService.h" +#include "MltResponse.h" using namespace Mlt; #include @@ -29,7 +30,10 @@ static valerie_response mlt_miracle_execute( void *arg, char *command ) Miracle *miracle = ( Miracle * )arg; if ( miracle != NULL ) { - return miracle->execute( command ); + Response *response = miracle->execute( command ); + valerie_response real = valerie_response_clone( response->get_response( ) ); + delete response; + return real; } else { @@ -45,7 +49,10 @@ static valerie_response mlt_miracle_push( void *arg, char *command, mlt_service if ( miracle != NULL ) { Service input( service ); - return miracle->push( command, &input ); + Response *response = miracle->push( command, &input ); + valerie_response real = valerie_response_clone( response->get_response( ) ); + delete response; + return real; } else { @@ -84,14 +91,14 @@ bool Miracle::is_running( ) return server->shutdown == 0; } -valerie_response Miracle::execute( char *command ) +Response *Miracle::execute( char *command ) { - return _execute( _real, command ); + return new Response( _execute( _real, command ) ); } -valerie_response Miracle::push( char *command, Service *service ) +Response *Miracle::push( char *command, Service *service ) { - return _push( _real, command, service->get_service( ) ); + return new Response( _push( _real, command, service->get_service( ) ) ); } void Miracle::wait_for_shutdown( ) diff --git a/mlt++/src/MltMiracle.h b/mlt++/src/MltMiracle.h index 60161593..7e6938d3 100644 --- a/mlt++/src/MltMiracle.h +++ b/mlt++/src/MltMiracle.h @@ -27,6 +27,7 @@ namespace Mlt { class Service; + class Response; class Miracle { @@ -40,8 +41,8 @@ namespace Mlt virtual ~Miracle( ); bool start( ); bool is_running( ); - virtual valerie_response execute( char *command ); - virtual valerie_response push( char *command, Service *service ); + virtual Response *execute( char *command ); + virtual Response *push( char *command, Service *service ); void wait_for_shutdown( ); }; } diff --git a/mlt++/src/MltResponse.cpp b/mlt++/src/MltResponse.cpp new file mode 100644 index 00000000..31dc0025 --- /dev/null +++ b/mlt++/src/MltResponse.cpp @@ -0,0 +1,59 @@ +/** + * MltResponse.cpp - MLT Wrapper + * Copyright (C) 2004-2005 Charles Yates + * Author: Charles Yates + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "MltResponse.h" +using namespace Mlt; + +Response::Response( valerie_response response ) : + _response( response ) +{ +} + +Response::~Response( ) +{ + valerie_response_close( _response ); +} + +valerie_response Response::get_response( ) +{ + return _response; +} + +int Response::error_code( ) +{ + return valerie_response_get_error_code( get_response( ) ); +} + +char *Response::error_string( ) +{ + return valerie_response_get_error_string( get_response( ) ); +} + +char *Response::get( int index ) +{ + return valerie_response_get_line( get_response( ), index ); +} + +int Response::count( ) +{ + return valerie_response_count( get_response( ) ); +} + + diff --git a/mlt++/src/MltResponse.h b/mlt++/src/MltResponse.h new file mode 100644 index 00000000..2c97a710 --- /dev/null +++ b/mlt++/src/MltResponse.h @@ -0,0 +1,43 @@ +/** + * MltResponse.h - MLT Wrapper + * Copyright (C) 2004-2005 Charles Yates + * Author: Charles Yates + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef _MLTPP_RESPONSE_H_ +#define _MLTPP_RESPONSE_H_ + +#include + +namespace Mlt +{ + class Response + { + private: + valerie_response _response; + public: + Response( valerie_response response ); + ~Response( ); + valerie_response get_response( ); + int error_code( ); + char *error_string( ); + char *get( int ); + int count( ); + }; +} + +#endif diff --git a/mlt++/swig/mltpp.i b/mlt++/swig/mltpp.i index 29499b21..8f497248 100644 --- a/mlt++/swig/mltpp.i +++ b/mlt++/swig/mltpp.i @@ -45,6 +45,8 @@ namespace Mlt { %newobject Tractor::multitrack( ); %newobject Tractor::field( ); %newobject Tractor::track( int ); +%newobject Miracle::execute( char * ); +%newobject Miracle::push( char *, Service & ); } /** Classes to wrap. @@ -67,6 +69,7 @@ namespace Mlt { %include %include %include +%include #if defined(SWIGRUBY) -- 2.39.2