X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Futils_videotl.cc;h=ed1bfad766eafbeb8c2fe996deb2acdeff583205;hb=ee1b49f87e4b8e6406c059f29371892872d3fb85;hp=1496893e82d3ea1db7285aa14e0f83bcb183656a;hpb=6a436fd826d1c9d88b60287696cc0836ccce35aa;p=ardour.git diff --git a/gtk2_ardour/utils_videotl.cc b/gtk2_ardour/utils_videotl.cc index 1496893e82..ed1bfad766 100644 --- a/gtk2_ardour/utils_videotl.cc +++ b/gtk2_ardour/utils_videotl.cc @@ -35,9 +35,10 @@ using namespace Gtk; using namespace std; using namespace PBD; using namespace ARDOUR; +using namespace VideoUtils; 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 */ size_t look_here = 0; @@ -77,7 +78,7 @@ confirm_video_outfn (std::string outfn, std::string docroot) } 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; 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 -video_get_docroot (ARDOUR::RCConfiguration* config) +VideoUtils::video_get_docroot (ARDOUR::RCConfiguration* config) { if (config->get_video_advanced_setup()) { return config->get_video_server_docroot(); @@ -101,7 +102,7 @@ video_get_docroot (ARDOUR::RCConfiguration* config) } std::string -video_get_server_url (ARDOUR::RCConfiguration* config) +VideoUtils::video_get_server_url (ARDOUR::RCConfiguration* config) { if (config->get_video_advanced_setup()) { return config->get_video_server_url(); @@ -111,7 +112,7 @@ video_get_server_url (ARDOUR::RCConfiguration* config) std::string -strip_file_extension (const std::string infile) +VideoUtils::strip_file_extension (const std::string infile) { std::string rv; char *ext, *bn = strdup(infile.c_str()); @@ -126,7 +127,7 @@ strip_file_extension (const std::string infile) } std::string -get_file_extension (const std::string infile) +VideoUtils::get_file_extension (const std::string infile) { std::string rv = ""; char *ext, *bn = strdup(infile.c_str()); @@ -140,13 +141,13 @@ get_file_extension (const std::string infile) } 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"; } 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; @@ -179,7 +180,7 @@ video_map_path (std::string server_docroot, std::string filepath) } void -ParseCSV (const std::string &csv, std::vector > &lines) +VideoUtils::ParseCSV (const std::string &csv, std::vector > &lines) { bool inQuote(false); bool newLine(false); @@ -236,7 +237,7 @@ ParseCSV (const std::string &csv, std::vector > &lines) } bool -video_query_info ( +VideoUtils::video_query_info ( std::string video_server_url, std::string filepath, double &video_file_fps, @@ -247,54 +248,32 @@ video_query_info ( { char url[2048]; - snprintf(url, sizeof(url), "%s%sinfo/?file=%s&format=plain" + snprintf(url, sizeof(url), "%s%sinfo/?file=%s&format=csv" , video_server_url.c_str() , (video_server_url.length()>0 && video_server_url.at(video_server_url.length()-1) == '/')?"":"/" , filepath.c_str()); - char *res = curl_http_get(url, NULL); - int pid=0; -#ifndef COMPILER_MINGW - if (res) { - char *pch, *pst; - int version; - pch = strtok_r(res, "\n", &pst); - while (pch) { -#if 0 /* DEBUG */ - printf("VideoFileInfo [%i] -> '%s'\n", pid, pch); -#endif - switch (pid) { - case 0: - version = atoi(pch); - if (version != 1) break; - case 1: - video_file_fps = atof(pch); - break; - case 2: - video_duration = atoll(pch); - break; - case 3: - video_start_offset = atof(pch); - break; - case 4: - video_aspect_ratio = atof(pch); - break; - default: - break; - } - pch = strtok_r(NULL,"\n", &pst); - ++pid; - } - free(res); + char *res = a3_curl_http_get(url, NULL); + if (!res) { + return false; } -#endif - if (pid!=5) { + + std::vector > lines; + ParseCSV(std::string(res), lines); + free(res); + + if (lines.empty() || lines.at(0).empty() || lines.at(0).size() != 6) { return false; } + if (atoi(lines.at(0).at(0)) != 1) return false; // version + video_start_offset = 0.0; + video_aspect_ratio = atof (lines.at(0).at(3)); + video_file_fps = atof (lines.at(0).at(4)); + video_duration = atoll(lines.at(0).at(5)); return true; } void -video_draw_cross (Glib::RefPtr img) +VideoUtils::video_draw_cross (Glib::RefPtr img) { int rowstride = img->get_rowstride(); @@ -321,7 +300,7 @@ video_draw_cross (Glib::RefPtr img) extern "C" { #include - struct MemoryStruct { + struct A3MemoryStruct { char *data; size_t size; }; @@ -329,7 +308,7 @@ extern "C" { static size_t WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data) { 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); if (mem->data) { @@ -340,10 +319,10 @@ extern "C" { return realsize; } - char *curl_http_get (const char *u, int *status) { + char *a3_curl_http_get (const char *u, int *status) { CURL *curl; CURLcode res; - struct MemoryStruct chunk; + struct A3MemoryStruct chunk; long int httpstatus; if (status) *status = 0; //usleep(500000); return NULL; // TEST & DEBUG @@ -372,7 +351,7 @@ extern "C" { if (status) *status = httpstatus; if (res) { #ifdef CURLERRORDEBUG - printf("curl_http_get() failed: %s\n", curlerror); + printf("a3_curl_http_get() failed: %s\n", curlerror); #endif return NULL; }