mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1138320 - Set screensharing mode or video mode for WebRTC video sources r=jesup
This commit is contained in:
parent
25a8fd36fb
commit
b6128d188d
@ -15,6 +15,8 @@
|
||||
|
||||
#include "ImageContainer.h"
|
||||
|
||||
#include "webrtc/common_types.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace mozilla {
|
||||
@ -298,6 +300,7 @@ public:
|
||||
VideoType video_type,
|
||||
uint64_t capture_time) = 0;
|
||||
|
||||
virtual MediaConduitErrorCode ConfigureCodecMode(webrtc::VideoCodecMode) = 0;
|
||||
/**
|
||||
* Function to configure send codec for the video session
|
||||
* @param sendSessionConfig: CodecConfiguration
|
||||
|
@ -81,7 +81,8 @@ WebrtcVideoConduit::WebrtcVideoConduit():
|
||||
mVideoLatencyAvg(0),
|
||||
mMinBitrate(200),
|
||||
mStartBitrate(300),
|
||||
mMaxBitrate(2000)
|
||||
mMaxBitrate(2000),
|
||||
mCodecMode(webrtc::kRealtimeVideo)
|
||||
{
|
||||
}
|
||||
|
||||
@ -538,7 +539,13 @@ WebrtcVideoConduit::SetReceiverTransport(mozilla::RefPtr<TransportInterface> aTr
|
||||
mReceiverTransport = aTransport;
|
||||
return kMediaConduitNoError;
|
||||
}
|
||||
|
||||
MediaConduitErrorCode
|
||||
WebrtcVideoConduit::ConfigureCodecMode(webrtc::VideoCodecMode mode)
|
||||
{
|
||||
CSFLogDebug(logTag, "%s ", __FUNCTION__);
|
||||
mCodecMode = mode;
|
||||
return kMediaConduitNoError;
|
||||
}
|
||||
/**
|
||||
* Note: Setting the send-codec on the Video Engine will restart the encoder,
|
||||
* sets up new SSRC and reset RTP_RTCP module with the new codec setting.
|
||||
@ -590,7 +597,7 @@ WebrtcVideoConduit::ConfigureSendMediaCodec(const VideoCodecConfig* codecConfig)
|
||||
#endif
|
||||
video_codec.qpMax = 56;
|
||||
video_codec.numberOfSimulcastStreams = 1;
|
||||
video_codec.mode = webrtc::kRealtimeVideo;
|
||||
video_codec.mode = mCodecMode;
|
||||
|
||||
codecFound = true;
|
||||
} else {
|
||||
|
@ -99,6 +99,11 @@ public:
|
||||
virtual MediaConduitErrorCode StopReceiving() MOZ_OVERRIDE;
|
||||
virtual MediaConduitErrorCode StartReceiving() MOZ_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Function to configure sending codec mode for different content
|
||||
*/
|
||||
virtual MediaConduitErrorCode ConfigureCodecMode(webrtc::VideoCodecMode) MOZ_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Function to configure send codec for the video session
|
||||
* @param sendSessionConfig: CodecConfiguration
|
||||
@ -354,6 +359,7 @@ private:
|
||||
nsAutoPtr<VideoCodecStatistics> mVideoCodecStat;
|
||||
|
||||
nsAutoPtr<LoadManager> mLoadManager;
|
||||
webrtc::VideoCodecMode mCodecMode;
|
||||
};
|
||||
|
||||
} // end namespace
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "MediaEngine.h"
|
||||
#endif
|
||||
|
||||
#include "GmpVideoCodec.h"
|
||||
@ -753,6 +754,11 @@ MediaPipelineFactory::GetOrCreateVideoConduit(
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = ConfigureVideoCodecMode(aTrack,*conduit);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Take possession of this pointer
|
||||
ScopedDeletePtr<VideoCodecConfig> config(configRaw);
|
||||
|
||||
@ -774,6 +780,61 @@ MediaPipelineFactory::GetOrCreateVideoConduit(
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
MediaPipelineFactory::ConfigureVideoCodecMode(const JsepTrack& aTrack,
|
||||
VideoSessionConduit& aConduit)
|
||||
{
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
nsRefPtr<LocalSourceStreamInfo> stream =
|
||||
mPCMedia->GetLocalStreamById(aTrack.GetStreamId());
|
||||
|
||||
//get video track
|
||||
nsRefPtr<mozilla::dom::VideoStreamTrack> videotrack =
|
||||
stream->GetVideoTrackByTrackId(aTrack.GetTrackId());
|
||||
|
||||
if (!videotrack) {
|
||||
MOZ_MTLOG(ML_ERROR, "video track not available");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
//get video source type
|
||||
nsRefPtr<DOMMediaStream> mediastream =
|
||||
mPCMedia->GetLocalStreamById(aTrack.GetStreamId())->GetMediaStream();
|
||||
|
||||
DOMLocalMediaStream* domLocalStream = mediastream->AsDOMLocalMediaStream();
|
||||
if (!domLocalStream) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
MediaEngineSource *engine =
|
||||
domLocalStream->GetMediaEngine(videotrack->GetTrackID());
|
||||
|
||||
dom::MediaSourceEnum source = engine->GetMediaSource();
|
||||
webrtc::VideoCodecMode mode = webrtc::kRealtimeVideo;
|
||||
switch (source) {
|
||||
case dom::MediaSourceEnum::Browser:
|
||||
case dom::MediaSourceEnum::Screen:
|
||||
case dom::MediaSourceEnum::Application:
|
||||
case dom::MediaSourceEnum::Window:
|
||||
mode = webrtc::kScreensharing;
|
||||
break;
|
||||
|
||||
case dom::MediaSourceEnum::Camera:
|
||||
default:
|
||||
mode = webrtc::kRealtimeVideo;
|
||||
break;
|
||||
}
|
||||
|
||||
auto error = aConduit.ConfigureCodecMode(mode);
|
||||
if (error) {
|
||||
MOZ_MTLOG(ML_ERROR, "ConfigureCodecMode failed: " << error);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add external H.264 video codec.
|
||||
*/
|
||||
|
@ -67,6 +67,9 @@ private:
|
||||
RefPtr<TransportFlow>* aRtcpOut,
|
||||
nsAutoPtr<MediaPipelineFilter>* aFilterOut);
|
||||
|
||||
nsresult ConfigureVideoCodecMode(const JsepTrack& aTrack,
|
||||
VideoSessionConduit& aConduit);
|
||||
|
||||
private:
|
||||
// Not owned, and assumed to exist as long as the factory.
|
||||
// The factory is a transient object, so this is fairly easy.
|
||||
|
@ -35,6 +35,8 @@
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/dom/RTCStatsReportBinding.h"
|
||||
#include "MediaStreamTrack.h"
|
||||
#include "VideoStreamTrack.h"
|
||||
#endif
|
||||
|
||||
|
||||
@ -1111,6 +1113,26 @@ SourceStreamInfo::AnyCodecHasPluginID(uint64_t aPluginID)
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
nsRefPtr<mozilla::dom::VideoStreamTrack>
|
||||
SourceStreamInfo::GetVideoTrackByTrackId(const std::string& trackId)
|
||||
{
|
||||
nsTArray<nsRefPtr<mozilla::dom::VideoStreamTrack>> videoTracks;
|
||||
|
||||
mMediaStream->GetVideoTracks(videoTracks);
|
||||
|
||||
for (size_t i = 0; i < videoTracks.Length(); ++i) {
|
||||
nsString aTrackId;
|
||||
videoTracks[i]->GetId(aTrackId);
|
||||
if (aTrackId.EqualsIgnoreCase(trackId.c_str())) {
|
||||
return videoTracks[i];
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
nsresult
|
||||
SourceStreamInfo::StorePipeline(
|
||||
const std::string& trackId,
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "VideoUtils.h"
|
||||
#include "ImageLayers.h"
|
||||
#include "VideoSegment.h"
|
||||
#include "MediaStreamTrack.h"
|
||||
#endif
|
||||
|
||||
class nsIPrincipal;
|
||||
@ -104,6 +105,9 @@ public:
|
||||
void DetachTransport_s();
|
||||
void DetachMedia_m();
|
||||
bool AnyCodecHasPluginID(uint64_t aPluginID);
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
nsRefPtr<mozilla::dom::VideoStreamTrack> GetVideoTrackByTrackId(const std::string& trackId);
|
||||
#endif
|
||||
protected:
|
||||
nsRefPtr<DOMMediaStream> mMediaStream;
|
||||
PeerConnectionMedia *mParent;
|
||||
|
Loading…
Reference in New Issue
Block a user