summaryrefslogtreecommitdiff
path: root/gtk2_ardour/utils_videotl.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2013-08-03 16:41:25 +0200
committerRobin Gareus <robin@gareus.org>2013-08-03 16:41:25 +0200
commitef3551300ad02de99160fa659edf6cd11040b5f3 (patch)
tree604c6f015262d844250b30a048c54e91a37a9b94 /gtk2_ardour/utils_videotl.cc
parentc06a3a620154e49e3c5370033cfb90dbed6f9652 (diff)
remove strtok_r() from video_query_info()
for minGW compatibility
Diffstat (limited to 'gtk2_ardour/utils_videotl.cc')
-rw-r--r--gtk2_ardour/utils_videotl.cc48
1 files changed, 14 insertions, 34 deletions
diff --git a/gtk2_ardour/utils_videotl.cc b/gtk2_ardour/utils_videotl.cc
index 504fc3d2eb..2a4ce21bdc 100644
--- a/gtk2_ardour/utils_videotl.cc
+++ b/gtk2_ardour/utils_videotl.cc
@@ -247,47 +247,27 @@ 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;
- 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);
+ if (!res) {
+ return false;
}
- if (pid!=5) {
+
+ std::vector<std::vector<std::string> > 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;
}