dedicated namespace for video-utils

conflicting symbol prophylaxis
This commit is contained in:
Robin Gareus 2013-08-03 16:54:57 +02:00 committed by Paul Davis
parent 520b09e82a
commit b5845ea458
9 changed files with 35 additions and 24 deletions

View file

@ -42,6 +42,7 @@ using namespace Gtk;
using namespace std; using namespace std;
using namespace PBD; using namespace PBD;
using namespace ARDOUR; using namespace ARDOUR;
using namespace VideoUtils;
#define PREVIEW_WIDTH (240) #define PREVIEW_WIDTH (240)
#define PREVIEW_HEIGHT (180) #define PREVIEW_HEIGHT (180)
@ -482,7 +483,7 @@ AddVideoDialog::harvid_request(std::string u)
harvid_list->clear(); harvid_list->clear();
char *res = curl_http_get(url, &status); char *res = a3_curl_http_get(url, &status);
if (status != 200) { if (status != 200) {
printf("request failed\n"); // XXX printf("request failed\n"); // XXX
harvid_path.set_text(" - request failed -"); harvid_path.set_text(" - request failed -");
@ -662,7 +663,7 @@ AddVideoDialog::request_preview(std::string u)
, (long long) (video_duration * seek_slider.get_value() / 1000.0) , (long long) (video_duration * seek_slider.get_value() / 1000.0)
, clip_width, clip_height, u.c_str()); , clip_width, clip_height, u.c_str());
char *data = curl_http_get(url, NULL); char *data = a3_curl_http_get(url, NULL);
if (!data) { if (!data) {
printf("image preview request failed %s\n", url); printf("image preview request failed %s\n", url);
imgbuf->fill(RGBA_TO_UINT(0,0,0,255)); imgbuf->fill(RGBA_TO_UINT(0,0,0,255));

View file

@ -60,6 +60,7 @@ using namespace Gtk;
using namespace std; using namespace std;
using namespace PBD; using namespace PBD;
using namespace ARDOUR; using namespace ARDOUR;
using namespace VideoUtils;
ExportVideoDialog::ExportVideoDialog (PublicEditor& ed, Session* s) ExportVideoDialog::ExportVideoDialog (PublicEditor& ed, Session* s)
: ArdourDialog (_("Export Video File ")) : ArdourDialog (_("Export Video File "))

View file

@ -33,6 +33,7 @@
#include "i18n.h" #include "i18n.h"
using namespace PBD; using namespace PBD;
using namespace VideoUtils;
TranscodeFfmpeg::TranscodeFfmpeg (std::string f) TranscodeFfmpeg::TranscodeFfmpeg (std::string f)
: infile(f) : infile(f)

View file

@ -50,6 +50,7 @@ using namespace Gtk;
using namespace std; using namespace std;
using namespace PBD; using namespace PBD;
using namespace ARDOUR; using namespace ARDOUR;
using namespace VideoUtils;
TranscodeVideoDialog::TranscodeVideoDialog (Session* s, std::string infile) TranscodeVideoDialog::TranscodeVideoDialog (Session* s, std::string infile)
: ArdourDialog (_("Transcode/Import Video File ")) : ArdourDialog (_("Transcode/Import Video File "))

View file

@ -35,9 +35,10 @@ using namespace Gtk;
using namespace std; using namespace std;
using namespace PBD; using namespace PBD;
using namespace ARDOUR; using namespace ARDOUR;
using namespace VideoUtils;
bool bool
confirm_video_outfn (std::string outfn, std::string docroot) VideoUtils::confirm_video_outfn (std::string outfn, std::string docroot)
{ {
/* replace docroot's '/' to G_DIR_SEPARATOR for the comparison */ /* replace docroot's '/' to G_DIR_SEPARATOR for the comparison */
size_t look_here = 0; size_t look_here = 0;
@ -77,7 +78,7 @@ confirm_video_outfn (std::string outfn, std::string docroot)
} }
std::string std::string
video_dest_dir (const std::string sessiondir, const std::string docroot) VideoUtils::video_dest_dir (const std::string sessiondir, const std::string docroot)
{ {
std::string dir = docroot; std::string dir = docroot;
if (dir.empty() || !dir.compare(0, dir.length(), sessiondir, 0, dir.length())) { if (dir.empty() || !dir.compare(0, dir.length(), sessiondir, 0, dir.length())) {
@ -92,7 +93,7 @@ video_dest_dir (const std::string sessiondir, const std::string docroot)
} }
std::string std::string
video_get_docroot (ARDOUR::RCConfiguration* config) VideoUtils::video_get_docroot (ARDOUR::RCConfiguration* config)
{ {
if (config->get_video_advanced_setup()) { if (config->get_video_advanced_setup()) {
return config->get_video_server_docroot(); return config->get_video_server_docroot();
@ -101,7 +102,7 @@ video_get_docroot (ARDOUR::RCConfiguration* config)
} }
std::string std::string
video_get_server_url (ARDOUR::RCConfiguration* config) VideoUtils::video_get_server_url (ARDOUR::RCConfiguration* config)
{ {
if (config->get_video_advanced_setup()) { if (config->get_video_advanced_setup()) {
return config->get_video_server_url(); return config->get_video_server_url();
@ -111,7 +112,7 @@ video_get_server_url (ARDOUR::RCConfiguration* config)
std::string std::string
strip_file_extension (const std::string infile) VideoUtils::strip_file_extension (const std::string infile)
{ {
std::string rv; std::string rv;
char *ext, *bn = strdup(infile.c_str()); char *ext, *bn = strdup(infile.c_str());
@ -126,7 +127,7 @@ strip_file_extension (const std::string infile)
} }
std::string std::string
get_file_extension (const std::string infile) VideoUtils::get_file_extension (const std::string infile)
{ {
std::string rv = ""; std::string rv = "";
char *ext, *bn = strdup(infile.c_str()); char *ext, *bn = strdup(infile.c_str());
@ -140,13 +141,13 @@ get_file_extension (const std::string infile)
} }
std::string std::string
video_dest_file (const std::string dir, const std::string infile) VideoUtils::video_dest_file (const std::string dir, const std::string infile)
{ {
return dir + "a3_" + strip_file_extension(Glib::path_get_basename(infile)) + ".avi"; return dir + "a3_" + strip_file_extension(Glib::path_get_basename(infile)) + ".avi";
} }
std::string std::string
video_map_path (std::string server_docroot, std::string filepath) VideoUtils::video_map_path (std::string server_docroot, std::string filepath)
{ {
std::string rv = filepath; std::string rv = filepath;
@ -179,7 +180,7 @@ video_map_path (std::string server_docroot, std::string filepath)
} }
void void
ParseCSV (const std::string &csv, std::vector<std::vector<std::string> > &lines) VideoUtils::ParseCSV (const std::string &csv, std::vector<std::vector<std::string> > &lines)
{ {
bool inQuote(false); bool inQuote(false);
bool newLine(false); bool newLine(false);
@ -236,7 +237,7 @@ ParseCSV (const std::string &csv, std::vector<std::vector<std::string> > &lines)
} }
bool bool
video_query_info ( VideoUtils::video_query_info (
std::string video_server_url, std::string video_server_url,
std::string filepath, std::string filepath,
double &video_file_fps, double &video_file_fps,
@ -251,7 +252,7 @@ video_query_info (
, video_server_url.c_str() , video_server_url.c_str()
, (video_server_url.length()>0 && video_server_url.at(video_server_url.length()-1) == '/')?"":"/" , (video_server_url.length()>0 && video_server_url.at(video_server_url.length()-1) == '/')?"":"/"
, filepath.c_str()); , filepath.c_str());
char *res = curl_http_get(url, NULL); char *res = a3_curl_http_get(url, NULL);
if (!res) { if (!res) {
return false; return false;
} }
@ -272,7 +273,7 @@ video_query_info (
} }
void void
video_draw_cross (Glib::RefPtr<Gdk::Pixbuf> img) VideoUtils::video_draw_cross (Glib::RefPtr<Gdk::Pixbuf> img)
{ {
int rowstride = img->get_rowstride(); int rowstride = img->get_rowstride();
@ -299,7 +300,7 @@ video_draw_cross (Glib::RefPtr<Gdk::Pixbuf> img)
extern "C" { extern "C" {
#include <curl/curl.h> #include <curl/curl.h>
struct MemoryStruct { struct A3MemoryStruct {
char *data; char *data;
size_t size; size_t size;
}; };
@ -307,7 +308,7 @@ extern "C" {
static size_t static size_t
WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data) { WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data) {
size_t realsize = size * nmemb; size_t realsize = size * nmemb;
struct MemoryStruct *mem = (struct MemoryStruct *)data; struct A3MemoryStruct *mem = (struct A3MemoryStruct *)data;
mem->data = (char *)realloc(mem->data, mem->size + realsize + 1); mem->data = (char *)realloc(mem->data, mem->size + realsize + 1);
if (mem->data) { if (mem->data) {
@ -318,10 +319,10 @@ extern "C" {
return realsize; return realsize;
} }
char *curl_http_get (const char *u, int *status) { char *a3_curl_http_get (const char *u, int *status) {
CURL *curl; CURL *curl;
CURLcode res; CURLcode res;
struct MemoryStruct chunk; struct A3MemoryStruct chunk;
long int httpstatus; long int httpstatus;
if (status) *status = 0; if (status) *status = 0;
//usleep(500000); return NULL; // TEST & DEBUG //usleep(500000); return NULL; // TEST & DEBUG
@ -350,7 +351,7 @@ extern "C" {
if (status) *status = httpstatus; if (status) *status = httpstatus;
if (res) { if (res) {
#ifdef CURLERRORDEBUG #ifdef CURLERRORDEBUG
printf("curl_http_get() failed: %s\n", curlerror); printf("a3_curl_http_get() failed: %s\n", curlerror);
#endif #endif
return NULL; return NULL;
} }

View file

@ -32,6 +32,8 @@
#include "ardour/template_utils.h" #include "ardour/template_utils.h"
#include "ardour_dialog.h" #include "ardour_dialog.h"
namespace VideoUtils {
bool confirm_video_outfn (std::string, std::string docroot=""); bool confirm_video_outfn (std::string, std::string docroot="");
std::string video_dest_dir (const std::string, const std::string); std::string video_dest_dir (const std::string, const std::string);
std::string video_dest_file (const std::string, const std::string); std::string video_dest_file (const std::string, const std::string);
@ -52,9 +54,10 @@ bool video_query_info (
double &video_start_offset, double &video_start_offset,
double &video_aspect_ratio double &video_aspect_ratio
); );
};
extern "C" { extern "C" {
char *curl_http_get (const char *u, int *status); char *a3_curl_http_get (const char *u, int *status);
} }
#endif /* __gtk_ardour_video_utils_h__ */ #endif /* __gtk_ardour_video_utils_h__ */

View file

@ -34,6 +34,7 @@
using namespace std; using namespace std;
using namespace ARDOUR; using namespace ARDOUR;
using namespace VideoUtils;
static void freedata_cb (uint8_t *d, void* /*arg*/) { static void freedata_cb (uint8_t *d, void* /*arg*/) {
/* later this can be used with libharvid /* later this can be used with libharvid
@ -209,7 +210,7 @@ http_get_thread (void *arg) {
int timeout = 1000; // * 5ms -> 5sec int timeout = 1000; // * 5ms -> 5sec
char *res = NULL; char *res = NULL;
do { do {
res=curl_http_get(url, &status); res=a3_curl_http_get(url, &status);
if (status == 503) usleep(5000); // try-again if (status == 503) usleep(5000); // try-again
} while (status == 503 && --timeout > 0); } while (status == 503 && --timeout > 0);

View file

@ -37,6 +37,7 @@ using namespace Gtk;
using namespace std; using namespace std;
using namespace PBD; using namespace PBD;
using namespace ARDOUR; using namespace ARDOUR;
using namespace VideoUtils;
VideoServerDialog::VideoServerDialog (Session* s) VideoServerDialog::VideoServerDialog (Session* s)
: ArdourDialog (_("Launch Video Server")) : ArdourDialog (_("Launch Video Server"))

View file

@ -43,6 +43,7 @@ using namespace std;
using namespace ARDOUR; using namespace ARDOUR;
using namespace PBD; using namespace PBD;
using namespace Timecode; using namespace Timecode;
using namespace VideoUtils;
VideoTimeLine::VideoTimeLine (PublicEditor *ed, ArdourCanvas::Group *vbg, int initial_height) VideoTimeLine::VideoTimeLine (PublicEditor *ed, ArdourCanvas::Group *vbg, int initial_height)
: editor (ed) : editor (ed)
@ -550,7 +551,7 @@ VideoTimeLine::check_server ()
, video_server_url.c_str() , video_server_url.c_str()
, (video_server_url.length()>0 && video_server_url.at(video_server_url.length()-1) == '/')?"":"/" , (video_server_url.length()>0 && video_server_url.at(video_server_url.length()-1) == '/')?"":"/"
); );
char *res=curl_http_get(url, NULL); char *res=a3_curl_http_get(url, NULL);
if (res) { if (res) {
if (strstr(res, "status: ok, online.")) { ok = true; } if (strstr(res, "status: ok, online.")) { ok = true; }
free(res); free(res);
@ -572,7 +573,7 @@ VideoTimeLine::check_server_docroot ()
, video_server_url.c_str() , video_server_url.c_str()
, (video_server_url.length()>0 && video_server_url.at(video_server_url.length()-1) == '/')?"":"/" , (video_server_url.length()>0 && video_server_url.at(video_server_url.length()-1) == '/')?"":"/"
); );
char *res=curl_http_get(url, NULL); char *res=a3_curl_http_get(url, NULL);
if (!res) { if (!res) {
return false; return false;
} }
@ -668,7 +669,7 @@ VideoTimeLine::flush_cache () {
, video_server_url.c_str() , video_server_url.c_str()
, (video_server_url.length()>0 && video_server_url.at(video_server_url.length()-1) == '/')?"":"/" , (video_server_url.length()>0 && video_server_url.at(video_server_url.length()-1) == '/')?"":"/"
); );
char *res=curl_http_get(url, NULL); char *res=a3_curl_http_get(url, NULL);
if (res) { if (res) {
free (res); free (res);
} }