summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormikhail.pozdnyakov <mikhail.pozdnyakov@intel.com>2016-03-14 07:29:34 -0700
committerCommit bot <commit-bot@chromium.org>2016-03-14 14:31:02 +0000
commitd17b1c983f3eb6feb99dab564b21cecc6e699f80 (patch)
tree688ce3ca33e79f9205e389cad4ec135135ccb694
parent3e7a9545bff26c2aa07ccf651f7dd9f353c9bdc9 (diff)
downloadchromium_src-d17b1c983f3eb6feb99dab564b21cecc6e699f80.zip
chromium_src-d17b1c983f3eb6feb99dab564b21cecc6e699f80.tar.gz
chromium_src-d17b1c983f3eb6feb99dab564b21cecc6e699f80.tar.bz2
MediaStreamVideoSource exports current video format
This patch adds a getter to the MediaStreamVideoSource class which returns the current video format. The video format details are necessary during establishing of WiFi Display session (for the capabilities negotiation with the sink). BUG=242107 Review URL: https://codereview.chromium.org/1672713002 Cr-Commit-Position: refs/heads/master@{#380969}
-rw-r--r--content/public/renderer/media_stream_api.cc14
-rw-r--r--content/public/renderer/media_stream_api.h8
-rw-r--r--content/renderer/media/media_stream_video_source.cc8
-rw-r--r--content/renderer/media/media_stream_video_source.h2
4 files changed, 32 insertions, 0 deletions
diff --git a/content/public/renderer/media_stream_api.cc b/content/public/renderer/media_stream_api.cc
index 5baaa54..a1cc697 100644
--- a/content/public/renderer/media_stream_api.cc
+++ b/content/public/renderer/media_stream_api.cc
@@ -13,6 +13,7 @@
#include "base/strings/utf_string_conversions.h"
#include "content/renderer/media/media_stream_audio_source.h"
#include "content/renderer/media/media_stream_video_capturer_source.h"
+#include "content/renderer/media/media_stream_video_source.h"
#include "content/renderer/media/media_stream_video_track.h"
#include "content/renderer/render_thread_impl.h"
#include "third_party/WebKit/public/platform/WebMediaStream.h"
@@ -112,4 +113,17 @@ bool AddAudioTrackToMediaStream(
return true;
}
+const media::VideoCaptureFormat* GetCurrentVideoTrackFormat(
+ const blink::WebMediaStreamTrack& video_track) {
+ if (video_track.isNull())
+ return nullptr;
+
+ content::MediaStreamVideoSource* source =
+ content::MediaStreamVideoSource::GetVideoSource(video_track.source());
+ if (!source)
+ return nullptr;
+
+ return source->GetCurrentFormat();
+}
+
} // namespace content
diff --git a/content/public/renderer/media_stream_api.h b/content/public/renderer/media_stream_api.h
index b87c93d..907415c 100644
--- a/content/public/renderer/media_stream_api.h
+++ b/content/public/renderer/media_stream_api.h
@@ -8,10 +8,12 @@
#include "content/common/content_export.h"
#include "media/base/audio_capturer_source.h"
#include "media/base/channel_layout.h"
+#include "media/base/video_capture_types.h"
#include "media/base/video_capturer_source.h"
namespace blink {
class WebMediaStream;
+class WebMediaStreamTrack;
}
namespace content {
@@ -41,6 +43,12 @@ CONTENT_EXPORT bool AddAudioTrackToMediaStream(
bool is_readonly,
blink::WebMediaStream* web_media_stream);
+// On success returns pointer to the current format of the given video track;
+// returns nullptr on failure (if the argument is invalid or if the format
+// cannot be retrieved at the moment).
+CONTENT_EXPORT const media::VideoCaptureFormat* GetCurrentVideoTrackFormat(
+ const blink::WebMediaStreamTrack& video_track);
+
} // namespace content
#endif // CONTENT_PUBLIC_RENDERER_MEDIA_STREAM_API_H_
diff --git a/content/renderer/media/media_stream_video_source.cc b/content/renderer/media/media_stream_video_source.cc
index f5e2eb1..9e4eeb9 100644
--- a/content/renderer/media/media_stream_video_source.cc
+++ b/content/renderer/media/media_stream_video_source.cc
@@ -401,6 +401,14 @@ base::SingleThreadTaskRunner* MediaStreamVideoSource::io_task_runner() const {
return track_adapter_->io_task_runner();
}
+const media::VideoCaptureFormat*
+ MediaStreamVideoSource::GetCurrentFormat() const {
+ DCHECK(CalledOnValidThread());
+ if (state_ == STARTING || state_ == STARTED)
+ return &current_format_;
+ return nullptr;
+}
+
void MediaStreamVideoSource::DoStopSource() {
DCHECK(CalledOnValidThread());
DVLOG(3) << "DoStopSource()";
diff --git a/content/renderer/media/media_stream_video_source.h b/content/renderer/media/media_stream_video_source.h
index e86a7d1..027ee38 100644
--- a/content/renderer/media/media_stream_video_source.h
+++ b/content/renderer/media/media_stream_video_source.h
@@ -87,6 +87,8 @@ class CONTENT_EXPORT MediaStreamVideoSource
// Returns the task runner where video frames will be delivered on.
base::SingleThreadTaskRunner* io_task_runner() const;
+ const media::VideoCaptureFormat* GetCurrentFormat() const;
+
protected:
void DoStopSource() override;