Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(467)

Unified Diff: media/ffmpeg/ffmpeg_common.cc

Issue 236023003: Add WebMediaPlayer::timelineOffset() support to WebMediaPlayerImpl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address CR comments Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/ffmpeg/ffmpeg_common.h ('k') | media/ffmpeg/ffmpeg_common_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/ffmpeg/ffmpeg_common.cc
diff --git a/media/ffmpeg/ffmpeg_common.cc b/media/ffmpeg/ffmpeg_common.cc
index 344e2656b9d4c4b004947aaf25df2e3ca01fb7e4..abc2a1a87d247a2f0968edac11ed6d63dca093d4 100644
--- a/media/ffmpeg/ffmpeg_common.cc
+++ b/media/ffmpeg/ffmpeg_common.cc
@@ -8,6 +8,7 @@
#include "base/logging.h"
#include "base/metrics/histogram.h"
#include "base/strings/string_number_conversions.h"
+#include "base/strings/string_util.h"
#include "media/base/decoder_buffer.h"
#include "media/base/video_frame.h"
#include "media/base/video_util.h"
@@ -550,4 +551,37 @@ PixelFormat VideoFormatToPixelFormat(VideoFrame::Format video_format) {
return PIX_FMT_NONE;
}
+bool FFmpegUTCDateToTime(const char* date_utc,
+ base::Time* out) {
+ DCHECK(date_utc);
+ DCHECK(out);
+
+ std::vector<std::string> fields;
+ std::vector<std::string> date_fields;
+ std::vector<std::string> time_fields;
+ base::Time::Exploded exploded;
+ exploded.millisecond = 0;
+
+ // TODO(acolwell): Update this parsing code when FFmpeg returns sub-second
+ // information.
+ if ((Tokenize(date_utc, " ", &fields) == 2) &&
+ (Tokenize(fields[0], "-", &date_fields) == 3) &&
+ (Tokenize(fields[1], ":", &time_fields) == 3) &&
+ base::StringToInt(date_fields[0], &exploded.year) &&
+ base::StringToInt(date_fields[1], &exploded.month) &&
+ base::StringToInt(date_fields[2], &exploded.day_of_month) &&
+ base::StringToInt(time_fields[0], &exploded.hour) &&
+ base::StringToInt(time_fields[1], &exploded.minute) &&
+ base::StringToInt(time_fields[2], &exploded.second)) {
+ base::Time parsed_time = base::Time::FromUTCExploded(exploded);
+ if (parsed_time.is_null())
+ return false;
+
+ *out = parsed_time;
+ return true;
+ }
+
+ return false;
+}
+
} // namespace media
« no previous file with comments | « media/ffmpeg/ffmpeg_common.h ('k') | media/ffmpeg/ffmpeg_common_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698