using boost::lexical_cast;
using boost::algorithm::trim;
-SubRip::SubRip (shared_ptr<SubRipContent> content)
+SubRip::SubRip (shared_ptr<const SubRipContent> content)
{
FILE* f = fopen_boost (content->path (0), "r");
if (!f) {
fclose (f);
}
-Time
+ContentTime
SubRip::convert_time (string t)
{
- Time r = 0;
+ ContentTime r;
vector<string> a;
boost::algorithm::split (a, t, boost::is_any_of (":"));
assert (a.size() == 3);
- r += lexical_cast<int> (a[0]) * 60 * 60 * TIME_HZ;
- r += lexical_cast<int> (a[1]) * 60 * TIME_HZ;
+ r += ContentTime::from_seconds (lexical_cast<int> (a[0]) * 60 * 60);
+ r += ContentTime::from_seconds (lexical_cast<int> (a[1]) * 60);
vector<string> b;
boost::algorithm::split (b, a[2], boost::is_any_of (","));
- r += lexical_cast<int> (b[0]) * TIME_HZ;
- r += lexical_cast<int> (b[1]) * TIME_HZ / 1000;
+ r += ContentTime::from_seconds (lexical_cast<int> (b[0]));
+ r += ContentTime::from_seconds (lexical_cast<float> (b[1]) / 1000);
return r;
}
return pieces;
}
-Time
+ContentTime
SubRip::length () const
{
if (_subtitles.empty ()) {
- return 0;
+ return ContentTime ();
}
return _subtitles.back().to;