Closed
Bug 951008
Opened 12 years ago
Closed 11 years ago
Media Recorder - fire onstart event when encoder start to generate encoded data
Categories
(Core :: Audio/Video: Recording, defect)
Tracking
()
RESOLVED
FIXED
mozilla33
People
(Reporter: rlin, Assigned: rlin)
References
Details
Attachments
(2 files, 4 obsolete files)
10.83 KB,
patch
|
khuey
:
review+
|
Details | Diff | Splinter Review |
10.84 KB,
patch
|
Details | Diff | Splinter Review |
On
https://dvcs.w3.org/hg/dap/raw-file/tip/media-stream-capture/MediaRecorder.html#widl-MediaRecorder-onstart
Start method:
Once data becomes available raise a start event and start gathering the data into a Blob (see [FILE-API]).
Assignee | ||
Updated•12 years ago
|
Assignee: nobody → rlin
Updated•12 years ago
|
Blocks: MediaRecording
Updated•12 years ago
|
Whiteboard: burirun1.3-2
Comment 1•12 years ago
|
||
This isn't related to any MozTrap test case that exists right now - this is a feature doesn't exist & does not have test cases mapped to it.
Whiteboard: burirun1.3-2
Updated•11 years ago
|
Component: Video/Audio → Video/Audio: Recording
Updated•11 years ago
|
No longer blocks: MediaRecording
Comment 2•11 years ago
|
||
Fails test case: https://moztrap.mozilla.org/manage/case/11593/
Whiteboard: burirun1.4-1
Comment 3•11 years ago
|
||
Console enabled must be checked under Developer settings to see the onstart event. Removing whiteboard tag as it no longer fails the test case listed in comment #2.
Whiteboard: burirun1.4-1
Assignee | ||
Comment 4•11 years ago
|
||
Free it if someone want it.
Assignee | ||
Updated•11 years ago
|
Assignee: rlin → nobody
Assignee | ||
Updated•11 years ago
|
Assignee: nobody → rlin
Assignee | ||
Comment 5•11 years ago
|
||
First patch for adding the onstart event.
Also contain the test case for this event.
Attachment #8446354 -
Flags: feedback?(jwwang)
Attachment #8446354 -
Flags: feedback?(jolin)
Attachment #8446354 -
Flags: feedback?(bechen)
Attachment #8446354 -
Flags: feedback?(ayang)
Comment 6•11 years ago
|
||
Comment on attachment 8446354 [details] [diff] [review]
patch v1
Review of attachment 8446354 [details] [diff] [review]:
-----------------------------------------------------------------
::: content/media/MediaRecorder.cpp
@@ +347,1 @@
> mEncodedBufferCache->AppendBuffer(encodedBuf[i]);
Nitty: Don't have to do this when hasData is false.
::: content/media/test/test_mediarecorder_record_getdata_afterstart.html
@@ +47,5 @@
> + mMediaRecorder.onstop = function() {
> + info('onstop fired successfully');
> + };
> +
> + mMediaRecorder.onstop = function() {
Why assign mMediaRecorder.onstop twice?
Attachment #8446354 -
Flags: feedback?(jolin) → feedback+
Comment 7•11 years ago
|
||
Comment on attachment 8446354 [details] [diff] [review]
patch v1
Review of attachment 8446354 [details] [diff] [review]:
-----------------------------------------------------------------
::: content/media/test/test_mediarecorder_record_getdata_afterstart.html
@@ +24,5 @@
> + var dest = context.createMediaStreamDestination();
> + source.connect(dest);
> + var elem = document.createElement('audio');
> + elem.mozSrcObject = dest.stream;
> + mMediaStream = dest.stream;
Why not just capture a stream from an audio element instead of going a long way through WebAudio?
@@ +55,5 @@
> + };
> +
> + mMediaRecorder.ondataavailable = function (e) {
> + if (mMediaRecorder.state == 'recording') {
> + ok(hasonstart, "should has onstart event first");
space
@@ +56,5 @@
> +
> + mMediaRecorder.ondataavailable = function (e) {
> + if (mMediaRecorder.state == 'recording') {
> + ok(hasonstart, "should has onstart event first");
> + is('audio/ogg', mMediaRecorder.mimeType, "check the record mimetype return " + mMediaRecorder.mimeType);
MIME type depends on available codec on the system which depends on pref settings. This check doesn't guarantee to be valid.
Attachment #8446354 -
Flags: feedback?(jwwang)
Comment 8•11 years ago
|
||
Comment on attachment 8446354 [details] [diff] [review]
patch v1
Review of attachment 8446354 [details] [diff] [review]:
-----------------------------------------------------------------
::: content/media/MediaRecorder.cpp
@@ +120,5 @@
> + // Fire start event and set mimeType, run in main thread task.
> + class DispatchStartEventRunnable : public nsRunnable
> + {
> + public:
> + DispatchStartEventRunnable(Session* aSession, const nsAString & aEventName)
nit
@@ +133,5 @@
> +
> + nsRefPtr<MediaRecorder> recorder = mSession->mRecorder;
> + if (!recorder) {
> + return NS_OK;
> + }
How about this?
NS_ENSURE_TRUE(mSession->mRecorder, NS_OK);
nsRefPtr<MediaRecorder> recorder = mSession->mRecorder;
@@ +134,5 @@
> + nsRefPtr<MediaRecorder> recorder = mSession->mRecorder;
> + if (!recorder) {
> + return NS_OK;
> + }
> + recorder->SetMimeType(mSession->mMimeType);
It looks like recorder->SetMimeType/GetMimeType are both accessed in main thread. Do we need Muxtex in http://dxr.mozilla.org/mozilla-central/source/content/media/MediaRecorder.h#111?
@@ +347,5 @@
> mEncodedBufferCache->AppendBuffer(encodedBuf[i]);
> + // Fire the start event when encoded data is available.
> + if (!mCanRetrieveData && hasData) {
> + NS_DispatchToMainThread(
> + new DispatchStartEventRunnable(this,NS_LITERAL_STRING("start")));
nit
@@ +508,5 @@
> // by calling requestData API.
> const int32_t mTimeSlice;
> // Indicate this session's stop has been called.
> bool mStopIssued;
> + // Indicate session has encoded data. can be changed in read thread.
Missing subject in second sentence?
So, what is "read thread"?
::: content/media/test/test_mediarecorder_record_getdata_afterstart.html
@@ +5,5 @@
> + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
> + <script type="text/javascript" src="manifest.js"></script>
> +</head>
> +<body>
bug id and url?
Attachment #8446354 -
Flags: feedback?(jolin)
Attachment #8446354 -
Flags: feedback?(ayang)
Attachment #8446354 -
Flags: feedback+
Updated•11 years ago
|
Attachment #8446354 -
Flags: feedback?(jolin)
Comment 9•11 years ago
|
||
Comment on attachment 8446354 [details] [diff] [review]
patch v1
Review of attachment 8446354 [details] [diff] [review]:
-----------------------------------------------------------------
::: content/media/MediaRecorder.cpp
@@ +509,5 @@
> const int32_t mTimeSlice;
> // Indicate this session's stop has been called.
> bool mStopIssued;
> + // Indicate session has encoded data. can be changed in read thread.
> + bool mCanRetrieveData;
Since the flag used only once for fire onstart event, I think the naming of the variable should be changed....
|mCanRetrieveData| tells me that the session has encoded data.
Attachment #8446354 -
Flags: feedback?(bechen) → feedback+
Assignee | ||
Comment 10•11 years ago
|
||
Correct those nits, thanks for your feedback.
About the mimeType in Session problem, I had a check and those operation is in the main thread. So I don't add mutex for that one. And the GetMimeType/SetMimeType funcitons have mutex to protect it.
About the mCanRetrieveData naming, because the client can get the encoded data after onstart event, so it imply we already have encoded data for application.
Attachment #8446354 -
Attachment is obsolete: true
Attachment #8446434 -
Flags: feedback?(jwwang)
Attachment #8446434 -
Flags: feedback?(jolin)
Attachment #8446434 -
Flags: feedback?(ayang)
Comment 11•11 years ago
|
||
(In reply to Randy Lin [:rlin] from comment #10)
> Created attachment 8446434 [details] [diff] [review]
> patch v2
>
> Correct those nits, thanks for your feedback.
>
> About the mimeType in Session problem, I had a check and those operation is
> in the main thread. So I don't add mutex for that one. And the
> GetMimeType/SetMimeType funcitons have mutex to protect it.
Hmmm...
I mean it DOES NOT need a muxtex for GetMimeType/SetMimeType functions.
Updated•11 years ago
|
Attachment #8446434 -
Flags: feedback?(ayang)
Comment 12•11 years ago
|
||
Comment on attachment 8446434 [details] [diff] [review]
patch v2
Review of attachment 8446434 [details] [diff] [review]:
-----------------------------------------------------------------
::: content/media/test/test_mediarecorder_record_getdata_afterstart.html
@@ +59,5 @@
> + }
> + };
> +
> + // Start recording once canplaythrough fires
> + element.oncanplaythrough = function() {
You should listen to 'loadedmetadata' instead of 'canplaythrough' for 'canplaythrough' will not necessarily fire depending on download speed.
Attachment #8446434 -
Flags: feedback?(jwwang) → feedback+
Assignee | ||
Comment 13•11 years ago
|
||
Hi Roc,
Could you review this?
Attachment #8446434 -
Attachment is obsolete: true
Attachment #8446434 -
Flags: feedback?(jolin)
Attachment #8447000 -
Flags: review?(roc)
Comment on attachment 8447000 [details] [diff] [review]
patch v2.1
Review of attachment 8447000 [details] [diff] [review]:
-----------------------------------------------------------------
::: content/media/test/test_mediarecorder_record_getdata_afterstart.html
@@ +37,5 @@
> + mMediaRecorder.onstart = function() {
> + info('onstart fired successfully');
> + hasonstart = true;
> + // On audio only case, we produce audio/ogg as mimeType.
> + ok('audio/ogg', mMediaRecorder.mimeType, "check the record mimetype return " + mMediaRecorder.mimeType);
This should be "is" not "ok"!
@@ +60,5 @@
> + };
> +
> + // Start recording once canplaythrough fires
> + element.onloadedmetadata = function() {
> + element.oncanplaythrough = null;
Fix comment and clearing this event handler
Attachment #8447000 -
Flags: review?(roc) → review+
Assignee | ||
Comment 15•11 years ago
|
||
Carry reviewer as roc.
Fix 2 nits.
Try result
https://tbpl.mozilla.org/?tree=Try&rev=a6a0adc6706d
Assignee | ||
Updated•11 years ago
|
Keywords: checkin-needed
Comment 16•11 years ago
|
||
checkin failed:
remote: WebIDL file dom/webidl/MediaRecorder.webidl altered in changeset 541378c6c4ad without DOM peer review
remote: Changes to WebIDL files in this repo require review from a DOM peer in the form of r=...
so i guess this needs dom peer review ?
Keywords: checkin-needed
Comment 17•11 years ago
|
||
Comment on attachment 8447834 [details] [diff] [review]
check-in patch
Review of attachment 8447834 [details] [diff] [review]:
-----------------------------------------------------------------
::: content/media/MediaRecorder.cpp
@@ +341,5 @@
> mEncoder->GetEncodedData(&encodedBuf, mMimeType);
>
> // Append pulled data into cache buffer.
> for (uint32_t i = 0; i < encodedBuf.Length(); i++) {
> + if (encodedBuf[i].Length() > 0) {
IsEmpty() exists
Assignee | ||
Comment 18•11 years ago
|
||
Hi Kyle,
Could you help to review the API part?
Attachment #8447000 -
Attachment is obsolete: true
Attachment #8447834 -
Attachment is obsolete: true
Attachment #8449124 -
Flags: superreview?(khuey)
Comment on attachment 8449124 [details] [diff] [review]
patch v2.2
Review of attachment 8449124 [details] [diff] [review]:
-----------------------------------------------------------------
You mean the WebIDL change? r=me.
Attachment #8449124 -
Flags: superreview?(khuey) → review+
Assignee | ||
Comment 20•11 years ago
|
||
Thanks khuey for reviewing the webidl part.
Carry sr = khuey.
Assignee | ||
Updated•11 years ago
|
Keywords: checkin-needed
Comment 21•11 years ago
|
||
Keywords: checkin-needed
Comment 22•11 years ago
|
||
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla33
You need to log in
before you can comment on or make changes to this bug.
Description
•