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

Unified Diff: media/webm/webm_stream_parser.cc

Issue 23702007: Render inband text tracks in the media pipeline (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: incorporate aaron's comments (10/16) Created 7 years, 2 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
« media/webm/webm_cluster_parser.cc ('K') | « media/webm/webm_stream_parser.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/webm/webm_stream_parser.cc
diff --git a/media/webm/webm_stream_parser.cc b/media/webm/webm_stream_parser.cc
index 12be44926842e3d0bd09abc082cd4d9b0adf2830..8374670d6380111fd657edbf592abeb6cbf19e85 100644
--- a/media/webm/webm_stream_parser.cc
+++ b/media/webm/webm_stream_parser.cc
@@ -8,7 +8,6 @@
#include "base/callback.h"
#include "base/logging.h"
-#include "base/stl_util.h"
#include "media/webm/webm_cluster_parser.h"
#include "media/webm/webm_constants.h"
#include "media/webm/webm_content_encodings.h"
@@ -20,11 +19,11 @@ namespace media {
WebMStreamParser::WebMStreamParser()
: state_(kWaitingForInit),
+ enable_text_tracks_(false),
waiting_for_buffers_(false) {
}
WebMStreamParser::~WebMStreamParser() {
- STLDeleteValues(&text_track_map_);
}
void WebMStreamParser::Init(const InitCB& init_cb,
@@ -32,7 +31,7 @@ void WebMStreamParser::Init(const InitCB& init_cb,
const NewBuffersCB& new_buffers_cb,
const NewTextBuffersCB& text_cb,
const NeedKeyCB& need_key_cb,
- const AddTextTrackCB& add_text_track_cb,
+ bool enable_text_tracks,
const NewMediaSegmentCB& new_segment_cb,
const base::Closure& end_of_segment_cb,
const LogCB& log_cb) {
@@ -52,7 +51,7 @@ void WebMStreamParser::Init(const InitCB& init_cb,
new_buffers_cb_ = new_buffers_cb;
text_cb_ = text_cb;
need_key_cb_ = need_key_cb;
- add_text_track_cb_ = add_text_track_cb;
+ enable_text_tracks_ = enable_text_tracks;
new_segment_cb_ = new_segment_cb;
end_of_segment_cb_ = end_of_segment_cb;
log_cb_ = log_cb;
@@ -175,7 +174,7 @@ int WebMStreamParser::ParseInfoAndTracks(const uint8* data, int size) {
cur_size -= result;
bytes_parsed += result;
- WebMTracksParser tracks_parser(log_cb_, add_text_track_cb_.is_null());
+ WebMTracksParser tracks_parser(log_cb_, !enable_text_tracks_);
result = tracks_parser.Parse(cur, cur_size);
if (result <= 0)
@@ -199,10 +198,7 @@ int WebMStreamParser::ParseInfoAndTracks(const uint8* data, int size) {
if (video_config.is_encrypted())
FireNeedKey(tracks_parser.video_encryption_key_id());
- if (!config_cb_.Run(audio_config, video_config)) {
- DVLOG(1) << "New config data isn't allowed.";
- return -1;
- }
+ TextTrackConfigMap text_track_config_map;
typedef WebMTracksParser::TextTracks TextTracks;
const TextTracks& text_tracks = tracks_parser.text_tracks();
@@ -212,17 +208,17 @@ int WebMStreamParser::ParseInfoAndTracks(const uint8* data, int size) {
const WebMTracksParser::TextTrackInfo& text_track_info = itr->second;
// TODO(matthewjheaney): verify that WebVTT uses ISO 639-2 for lang
- scoped_ptr<TextTrack> text_track =
- add_text_track_cb_.Run(text_track_info.kind,
- text_track_info.name,
- text_track_info.language);
- // Assume ownership of pointer, and cache the text track object, for use
- // later when we have text track buffers. (The text track objects are
- // deallocated in the dtor for this class.)
+ text_track_config_map.insert(
+ std::make_pair(itr->first,
+ TextTrackConfig(text_track_info.kind,
+ text_track_info.name,
+ text_track_info.language)));
+ }
- if (text_track)
- text_track_map_.insert(std::make_pair(itr->first, text_track.release()));
+ if (!config_cb_.Run(audio_config, video_config, text_track_config_map)) {
+ DVLOG(1) << "New config data isn't allowed.";
+ return -1;
}
cluster_parser_.reset(new WebMClusterParser(
@@ -301,14 +297,7 @@ int WebMStreamParser::ParseCluster(const uint8* data, int size) {
const BufferQueue* text_buffers;
while (text_track_iter(&text_track_num, &text_buffers)) {
- TextTrackMap::iterator find_result = text_track_map_.find(text_track_num);
-
- if (find_result == text_track_map_.end())
- continue;
-
- TextTrack* const text_track = find_result->second;
-
- if (!text_buffers->empty() && !text_cb_.Run(text_track, *text_buffers))
+ if (!text_buffers->empty() && !text_cb_.Run(text_track_num, *text_buffers))
return -1;
}
« media/webm/webm_cluster_parser.cc ('K') | « media/webm/webm_stream_parser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698