From 55c7a3bf01ddbc22620eccbf682f5094e6be97e3 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 13 Nov 2012 16:14:25 +0000 Subject: add timecode format parser git-svn-id: svn://localhost/ardour2/branches/3.0@13479 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/timecode/src/time.cc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'libs/timecode/src/time.cc') diff --git a/libs/timecode/src/time.cc b/libs/timecode/src/time.cc index 10dfd2fb59..b39da34d6d 100644 --- a/libs/timecode/src/time.cc +++ b/libs/timecode/src/time.cc @@ -623,6 +623,24 @@ std::string timecode_format_sampletime ( return timecode_format_time(t); } +bool parse_timecode_format(std::string tc, Timecode::Time &TC) { + char negative[2]; + char ignored[2]; + TC.subframes = 0; + if (sscanf (tc.c_str(), "%[- ]%" PRId32 ":%" PRId32 ":%" PRId32 "%[:;]%" PRId32, + negative, &TC.hours, &TC.minutes, &TC.seconds, ignored, &TC.frames) != 6) { + TC.hours = TC.minutes = TC.seconds = TC.frames = 0; + TC.negative = false; + return false; + } + if (negative[0]=='-') { + TC.negative = true; + } else { + TC.negative = false; + } + return true; +} + void timecode_to_sample( Timecode::Time& timecode, int64_t& sample, -- cgit v1.2.3