Fix crashes in FFmpegDemuxer::SetEnabled

What happens here is similar to crbug.com/775852 - somehow an invalid
track id is passed from blink level down to media pipeline and we fail
to find the demuxer stream corresponding to that track id. So instead
of using map operator[], we need to use map::find and check if the
stream for the given track id was actually found.

BUG=806871

Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: Ibbffc74046a562585d6b404f90a9ae38a0d43050
Reviewed-on: https://chromium-review.googlesource.com/902188
Reviewed-by: Dale Curtis <dalecurtis@chromium.org>
Commit-Queue: Sergey Volk <servolk@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#534515}(cherry picked from commit 50f000d66dd5a2c512daf1fec265fc4e9668e6ab)
Reviewed-on: https://chromium-review.googlesource.com/937822
Reviewed-by: Sergey Volk <servolk@chromium.org>
Cr-Commit-Position: refs/branch-heads/3325@{#592}
Cr-Branched-From: bc084a8b5afa3744a74927344e304c02ae54189f-refs/heads/master@{#530369}
diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc
index 1daed01..2143e474 100644
--- a/media/filters/ffmpeg_demuxer.cc
+++ b/media/filters/ffmpeg_demuxer.cc
@@ -1709,8 +1709,10 @@
 
   std::set<FFmpegDemuxerStream*> enabled_streams;
   for (const auto& id : track_ids) {
-    FFmpegDemuxerStream* stream = track_id_to_demux_stream_map_[id];
-    DCHECK(stream);
+    auto it = track_id_to_demux_stream_map_.find(id);
+    if (it == track_id_to_demux_stream_map_.end())
+      continue;
+    FFmpegDemuxerStream* stream = it->second;
     DCHECK_EQ(DemuxerStream::AUDIO, stream->type());
     // TODO(servolk): Remove after multiple enabled audio tracks are supported
     // by the media::RendererImpl.
@@ -1745,9 +1747,12 @@
 
   FFmpegDemuxerStream* selected_stream = nullptr;
   if (track_id) {
-    selected_stream = track_id_to_demux_stream_map_[*track_id];
-    DCHECK(selected_stream);
-    DCHECK_EQ(DemuxerStream::VIDEO, selected_stream->type());
+    auto it = track_id_to_demux_stream_map_.find(*track_id);
+    if (it != track_id_to_demux_stream_map_.end()) {
+      selected_stream = it->second;
+      DCHECK(selected_stream);
+      DCHECK_EQ(DemuxerStream::VIDEO, selected_stream->type());
+    }
   }
 
   // First disable all streams that need to be disabled and then enable the