chore(ff): remove some dead code (#6423)
This commit is contained in:
parent
9e36f5cc26
commit
765d74987f
|
|
@ -1,2 +1,2 @@
|
||||||
1252
|
1253
|
||||||
Changed: joel.einbinder@gmail.com Tue 04 May 2021 02:47:58 AM PDT
|
Changed: pavel.feldman@gmail.com Wed 05 May 2021 01:22:39 PM PDT
|
||||||
|
|
|
||||||
|
|
@ -488,7 +488,7 @@ class PageTarget {
|
||||||
return await this._channel.connect('').send('hasFailedToOverrideTimezone').catch(e => true);
|
return await this._channel.connect('').send('hasFailedToOverrideTimezone').catch(e => true);
|
||||||
}
|
}
|
||||||
|
|
||||||
async _startVideoRecording({width, height, scale, dir}) {
|
async _startVideoRecording({width, height, dir}) {
|
||||||
// On Mac the window may not yet be visible when TargetCreated and its
|
// On Mac the window may not yet be visible when TargetCreated and its
|
||||||
// NSWindow.windowNumber may be -1, so we wait until the window is known
|
// NSWindow.windowNumber may be -1, so we wait until the window is known
|
||||||
// to be initialized and visible.
|
// to be initialized and visible.
|
||||||
|
|
@ -496,16 +496,13 @@ class PageTarget {
|
||||||
const file = OS.Path.join(dir, helper.generateId() + '.webm');
|
const file = OS.Path.join(dir, helper.generateId() + '.webm');
|
||||||
if (width < 10 || width > 10000 || height < 10 || height > 10000)
|
if (width < 10 || width > 10000 || height < 10 || height > 10000)
|
||||||
throw new Error("Invalid size");
|
throw new Error("Invalid size");
|
||||||
if (scale && (scale <= 0 || scale > 1))
|
|
||||||
throw new Error("Unsupported scale");
|
|
||||||
|
|
||||||
const screencast = Cc['@mozilla.org/juggler/screencast;1'].getService(Ci.nsIScreencastService);
|
const screencast = Cc['@mozilla.org/juggler/screencast;1'].getService(Ci.nsIScreencastService);
|
||||||
const docShell = this._gBrowser.ownerGlobal.docShell;
|
const docShell = this._gBrowser.ownerGlobal.docShell;
|
||||||
// Exclude address bar and navigation control from the video.
|
// Exclude address bar and navigation control from the video.
|
||||||
const rect = this.linkedBrowser().getBoundingClientRect();
|
const rect = this.linkedBrowser().getBoundingClientRect();
|
||||||
const devicePixelRatio = this._window.devicePixelRatio;
|
const devicePixelRatio = this._window.devicePixelRatio;
|
||||||
const viewport = this._viewportSize || this._browserContext.defaultViewportSize || {width: 0, height: 0};
|
const videoSessionId = screencast.startVideoRecording(docShell, file, width, height, devicePixelRatio * rect.top);
|
||||||
const videoSessionId = screencast.startVideoRecording(docShell, file, width, height, viewport.width, viewport.height, scale || 0, devicePixelRatio * rect.top);
|
|
||||||
this._screencastInfo = { videoSessionId, file };
|
this._screencastInfo = { videoSessionId, file };
|
||||||
this.emit(PageTarget.Events.ScreencastStarted);
|
this.emit(PageTarget.Events.ScreencastStarted);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -379,10 +379,6 @@ class PageHandler {
|
||||||
throw new Error('ERROR: cannot find worker with id ' + workerId);
|
throw new Error('ERROR: cannot find worker with id ' + workerId);
|
||||||
return await worker.sendMessage(JSON.parse(message));
|
return await worker.sendMessage(JSON.parse(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
async ['Page.stopVideoRecording']() {
|
|
||||||
await this._pageTarget.stopVideoRecording();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = ['PageHandler'];
|
var EXPORTED_SYMBOLS = ['PageHandler'];
|
||||||
|
|
|
||||||
|
|
@ -426,7 +426,6 @@ const Browser = {
|
||||||
dir: t.String,
|
dir: t.String,
|
||||||
width: t.Number,
|
width: t.Number,
|
||||||
height: t.Number,
|
height: t.Number,
|
||||||
scale: t.Optional(t.Number),
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -896,16 +895,6 @@ const Page = {
|
||||||
message: t.String,
|
message: t.String,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'startVideoRecording': {
|
|
||||||
params: {
|
|
||||||
file: t.String,
|
|
||||||
width: t.Number,
|
|
||||||
height: t.Number,
|
|
||||||
scale: t.Optional(t.Number),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
'stopVideoRecording': {
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -110,9 +110,8 @@ void createImage(unsigned int width, unsigned int height,
|
||||||
|
|
||||||
class ScreencastEncoder::VPXFrame {
|
class ScreencastEncoder::VPXFrame {
|
||||||
public:
|
public:
|
||||||
VPXFrame(rtc::scoped_refptr<webrtc::VideoFrameBuffer>&& buffer, Maybe<double> scale, const gfx::IntMargin& margin)
|
VPXFrame(rtc::scoped_refptr<webrtc::VideoFrameBuffer>&& buffer, const gfx::IntMargin& margin)
|
||||||
: m_frameBuffer(std::move(buffer))
|
: m_frameBuffer(std::move(buffer))
|
||||||
, m_scale(scale)
|
|
||||||
, m_margin(margin)
|
, m_margin(margin)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
|
@ -137,8 +136,8 @@ public:
|
||||||
double src_width = src->width() - m_margin.LeftRight();
|
double src_width = src->width() - m_margin.LeftRight();
|
||||||
double src_height = src->height() - m_margin.top;
|
double src_height = src->height() - m_margin.top;
|
||||||
|
|
||||||
if (m_scale || (src_width > image->w || src_height > image->h)) {
|
if (src_width > image->w || src_height > image->h) {
|
||||||
double scale = m_scale ? m_scale.value() : std::min(image->w / src_width, image->h / src_height);
|
double scale = std::min(image->w / src_width, image->h / src_height);
|
||||||
double dst_width = src_width * scale;
|
double dst_width = src_width * scale;
|
||||||
if (dst_width > image->w) {
|
if (dst_width > image->w) {
|
||||||
src_width *= image->w / dst_width;
|
src_width *= image->w / dst_width;
|
||||||
|
|
@ -174,7 +173,6 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
rtc::scoped_refptr<webrtc::VideoFrameBuffer> m_frameBuffer;
|
rtc::scoped_refptr<webrtc::VideoFrameBuffer> m_frameBuffer;
|
||||||
Maybe<double> m_scale;
|
|
||||||
gfx::IntMargin m_margin;
|
gfx::IntMargin m_margin;
|
||||||
TimeDuration m_duration;
|
TimeDuration m_duration;
|
||||||
};
|
};
|
||||||
|
|
@ -276,9 +274,8 @@ private:
|
||||||
std::unique_ptr<vpx_image_t> m_image;
|
std::unique_ptr<vpx_image_t> m_image;
|
||||||
};
|
};
|
||||||
|
|
||||||
ScreencastEncoder::ScreencastEncoder(std::unique_ptr<VPXCodec>&& vpxCodec, Maybe<double> scale, const gfx::IntMargin& margin)
|
ScreencastEncoder::ScreencastEncoder(std::unique_ptr<VPXCodec>&& vpxCodec, const gfx::IntMargin& margin)
|
||||||
: m_vpxCodec(std::move(vpxCodec))
|
: m_vpxCodec(std::move(vpxCodec))
|
||||||
, m_scale(scale)
|
|
||||||
, m_margin(margin)
|
, m_margin(margin)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -287,7 +284,7 @@ ScreencastEncoder::~ScreencastEncoder()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<ScreencastEncoder> ScreencastEncoder::create(nsCString& errorString, const nsCString& filePath, int width, int height, Maybe<double> scale, const gfx::IntMargin& margin)
|
RefPtr<ScreencastEncoder> ScreencastEncoder::create(nsCString& errorString, const nsCString& filePath, int width, int height, const gfx::IntMargin& margin)
|
||||||
{
|
{
|
||||||
vpx_codec_iface_t* codec_interface = vpx_codec_vp8_cx();
|
vpx_codec_iface_t* codec_interface = vpx_codec_vp8_cx();
|
||||||
if (!codec_interface) {
|
if (!codec_interface) {
|
||||||
|
|
@ -328,7 +325,7 @@ RefPtr<ScreencastEncoder> ScreencastEncoder::create(nsCString& errorString, cons
|
||||||
|
|
||||||
std::unique_ptr<VPXCodec> vpxCodec(new VPXCodec(codec, cfg, file));
|
std::unique_ptr<VPXCodec> vpxCodec(new VPXCodec(codec, cfg, file));
|
||||||
// fprintf(stderr, "ScreencastEncoder initialized with: %s\n", vpx_codec_iface_name(codec_interface));
|
// fprintf(stderr, "ScreencastEncoder initialized with: %s\n", vpx_codec_iface_name(codec_interface));
|
||||||
return new ScreencastEncoder(std::move(vpxCodec), scale, margin);
|
return new ScreencastEncoder(std::move(vpxCodec), margin);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreencastEncoder::flushLastFrame()
|
void ScreencastEncoder::flushLastFrame()
|
||||||
|
|
@ -350,7 +347,7 @@ void ScreencastEncoder::encodeFrame(const webrtc::VideoFrame& videoFrame)
|
||||||
// fprintf(stderr, "ScreencastEncoder::encodeFrame\n");
|
// fprintf(stderr, "ScreencastEncoder::encodeFrame\n");
|
||||||
flushLastFrame();
|
flushLastFrame();
|
||||||
|
|
||||||
m_lastFrame = std::make_unique<VPXFrame>(videoFrame.video_frame_buffer(), m_scale, m_margin);
|
m_lastFrame = std::make_unique<VPXFrame>(videoFrame.video_frame_buffer(), m_margin);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreencastEncoder::finish(std::function<void()>&& callback)
|
void ScreencastEncoder::finish(std::function<void()>&& callback)
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,10 @@ class ScreencastEncoder {
|
||||||
public:
|
public:
|
||||||
static constexpr int fps = 25;
|
static constexpr int fps = 25;
|
||||||
|
|
||||||
static RefPtr<ScreencastEncoder> create(nsCString& errorString, const nsCString& filePath, int width, int height, Maybe<double> scale, const gfx::IntMargin& margin);
|
static RefPtr<ScreencastEncoder> create(nsCString& errorString, const nsCString& filePath, int width, int height, const gfx::IntMargin& margin);
|
||||||
|
|
||||||
class VPXCodec;
|
class VPXCodec;
|
||||||
ScreencastEncoder(std::unique_ptr<VPXCodec>&&, Maybe<double> scale, const gfx::IntMargin& margin);
|
ScreencastEncoder(std::unique_ptr<VPXCodec>&&, const gfx::IntMargin& margin);
|
||||||
|
|
||||||
void encodeFrame(const webrtc::VideoFrame& videoFrame);
|
void encodeFrame(const webrtc::VideoFrame& videoFrame);
|
||||||
|
|
||||||
|
|
@ -38,7 +38,6 @@ private:
|
||||||
void flushLastFrame();
|
void flushLastFrame();
|
||||||
|
|
||||||
std::unique_ptr<VPXCodec> m_vpxCodec;
|
std::unique_ptr<VPXCodec> m_vpxCodec;
|
||||||
Maybe<double> m_scale;
|
|
||||||
gfx::IntMargin m_margin;
|
gfx::IntMargin m_margin;
|
||||||
TimeStamp m_lastFrameTimestamp;
|
TimeStamp m_lastFrameTimestamp;
|
||||||
class VPXFrame;
|
class VPXFrame;
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ interface nsIDocShell;
|
||||||
[scriptable, uuid(d8c4d9e0-9462-445e-9e43-68d3872ad1de)]
|
[scriptable, uuid(d8c4d9e0-9462-445e-9e43-68d3872ad1de)]
|
||||||
interface nsIScreencastService : nsISupports
|
interface nsIScreencastService : nsISupports
|
||||||
{
|
{
|
||||||
AString startVideoRecording(in nsIDocShell docShell, in ACString fileName, in uint32_t width, in uint32_t height, in uint32_t viewportWidth, in uint32_t viewportHeight, in double scale, in int32_t offset_top);
|
AString startVideoRecording(in nsIDocShell docShell, in ACString fileName, in uint32_t width, in uint32_t height, in int32_t offset_top);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will emit 'juggler-screencast-stopped' when the video file is saved.
|
* Will emit 'juggler-screencast-stopped' when the video file is saved.
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,7 @@ nsScreencastService::nsScreencastService() = default;
|
||||||
nsScreencastService::~nsScreencastService() {
|
nsScreencastService::~nsScreencastService() {
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsScreencastService::StartVideoRecording(nsIDocShell* aDocShell, const nsACString& aFileName, uint32_t width, uint32_t height, uint32_t viewportWidth, uint32_t viewportHeight, double scale, int32_t offsetTop, nsAString& sessionId) {
|
nsresult nsScreencastService::StartVideoRecording(nsIDocShell* aDocShell, const nsACString& aFileName, uint32_t width, uint32_t height, int32_t offsetTop, nsAString& sessionId) {
|
||||||
MOZ_RELEASE_ASSERT(NS_IsMainThread(), "Screencast service must be started on the Main thread.");
|
MOZ_RELEASE_ASSERT(NS_IsMainThread(), "Screencast service must be started on the Main thread.");
|
||||||
|
|
||||||
PresShell* presShell = aDocShell->GetPresShell();
|
PresShell* presShell = aDocShell->GetPresShell();
|
||||||
|
|
@ -158,23 +158,16 @@ nsresult nsScreencastService::StartVideoRecording(nsIDocShell* aDocShell, const
|
||||||
if (!capturer)
|
if (!capturer)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
nsCString error;
|
|
||||||
Maybe<double> maybeScale;
|
|
||||||
if (scale)
|
|
||||||
maybeScale = Some(scale);
|
|
||||||
|
|
||||||
gfx::IntMargin margin;
|
gfx::IntMargin margin;
|
||||||
auto bounds = widget->GetScreenBounds().ToUnknownRect();
|
auto bounds = widget->GetScreenBounds().ToUnknownRect();
|
||||||
auto clientBounds = widget->GetClientBounds().ToUnknownRect();
|
auto clientBounds = widget->GetClientBounds().ToUnknownRect();
|
||||||
// The browser window has a minimum size, so it might be larger than the viewport size.
|
|
||||||
clientBounds.width = std::min((int)viewportWidth, clientBounds.width);
|
|
||||||
clientBounds.height = std::min((int)viewportHeight, clientBounds.height);
|
|
||||||
// Crop the image to exclude frame (if any).
|
// Crop the image to exclude frame (if any).
|
||||||
margin = bounds - clientBounds;
|
margin = bounds - clientBounds;
|
||||||
// Crop the image to exclude controls.
|
// Crop the image to exclude controls.
|
||||||
margin.top += offsetTop;
|
margin.top += offsetTop;
|
||||||
|
|
||||||
RefPtr<ScreencastEncoder> encoder = ScreencastEncoder::create(error, PromiseFlatCString(aFileName), width, height, maybeScale, margin);
|
nsCString error;
|
||||||
|
RefPtr<ScreencastEncoder> encoder = ScreencastEncoder::create(error, PromiseFlatCString(aFileName), width, height, margin);
|
||||||
if (!encoder) {
|
if (!encoder) {
|
||||||
fprintf(stderr, "Failed to create ScreencastEncoder: %s\n", error.get());
|
fprintf(stderr, "Failed to create ScreencastEncoder: %s\n", error.get());
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue