Closed
Bug 1050664
Opened 11 years ago
Closed 11 years ago
MediaCodecReader playback can't suspend/resume.
Categories
(Core :: Audio/Video, defect)
Tracking
()
People
(Reporter: bechen, Assigned: bechen)
References
Details
Attachments
(1 file, 4 obsolete files)
|
5.21 KB,
patch
|
bechen
:
review+
|
Details | Diff | Splinter Review |
STR:
1. enable MediaCodec preference
2. play a video or audio by browser
3. press home key
4. open browser again, the video/audio can't play anymore.
| Assignee | ||
Comment 1•11 years ago
|
||
Seems that we need to change the mPlayState to PLAY_STATE_LOADING like MediaOmxDecoder::ResumeStateMachine(), or the statemacheing keeps in dormant state.
http://dxr.mozilla.org/mozilla-central/source/content/media/omx/MediaOmxDecoder.cpp#120
| Assignee | ||
Updated•11 years ago
|
Target Milestone: --- → 2.1 S3 (29aug)
Updated•11 years ago
|
Assignee: nobody → bechen
feature-b2g: --- → 2.1
| Assignee | ||
Comment 2•11 years ago
|
||
As discussed with Bruce, we should not check the |mCodec| which mapping to real HW resource that will be released at dormant state. Makes the function |MediaCodecReader::IsDormantNeeded| not works.
We should check the mSource that indaicates the MediaCodec has video.
Attachment #8474929 -
Flags: review?(cpearce)
Attachment #8474929 -
Flags: review?(brsun)
Updated•11 years ago
|
Attachment #8474929 -
Flags: review?(brsun) → review+
Updated•11 years ago
|
Attachment #8474929 -
Flags: review?(cpearce) → review+
| Assignee | ||
Comment 3•11 years ago
|
||
Hmm, the patch only fix "can't play video after suspend/resume", there is still bugs inside.
STR:
1. enable MediaCodec preference, apply this patch
2. play a video by browser
3. seek to the middle of the video
4. suspend/resume by home key
We can observe that the timing on the control bar doesn't match to the video frame.
Seems that the timing of decoder is not sync to MediaDecoderStateMachine.
Symptoms:
1. EOS is triggered earlier. ex: a 3:50 video clip, the control bar jumps to the end when playing 3:43 frame.
2. Seek to the beginning of the clip, some frames are missing.
| Assignee | ||
Comment 4•11 years ago
|
||
Found root cause:
When the MediaDecoderStateMachine change the state from Dormant to Metadata, will invoke |mReader->ReadMetadata| then |mReader->RequestData|. After the mReader callback decoded data to StateMachine, the |mStartTime| in StateMachine will be updated.
Once the |mStartTime| is not zero, everything is wrong....
TODO: find out why the MediaOmxReader/Decoder works fine because the code flow is the same at StateMachine.
| Assignee | ||
Comment 5•11 years ago
|
||
Invoke mSource->stop at the ReleaseMediaResources() function and also add a new member |mSourceIsStopped| to protect the mSource->start/stop function.
Attachment #8474929 -
Attachment is obsolete: true
Attachment #8475797 -
Flags: review?(brsun)
Comment 6•11 years ago
|
||
Comment on attachment 8475797 [details] [diff] [review]
bug-1050664.patch
Review of attachment 8475797 [details] [diff] [review]:
-----------------------------------------------------------------
The timing to call MediaSource::start() and MediaSource::stop() is a little bit subtle. The logic to call OmxDecoder::Play() and OmxDecoder::Pause() in MediaOmxReader is much clearer. Perhaps we could mimic that logic from MediaOmxReader to have a clearer flow.
| Assignee | ||
Comment 7•11 years ago
|
||
As expected, the suspend/resume issue occurs at Bug 1033910 for rtsp.
When the StateMachine is in DECODER_STATE_DECODING_METADATA state, the mStartTime will be updated.
That implies the Rtsp must seek to zero(or do something like seek to zero) when the state is DECODER_STATE_DECODING_METADATA or DECODER_STATE_DORMANT, in order to set the mStartTime correctly.
It will be a problem for rtsp.
| Assignee | ||
Comment 8•11 years ago
|
||
(In reply to Bruce Sun [:brsun] from comment #6)
> Comment on attachment 8475797 [details] [diff] [review]
> bug-1050664.patch
>
> Review of attachment 8475797 [details] [diff] [review]:
> -----------------------------------------------------------------
>
> The timing to call MediaSource::start() and MediaSource::stop() is a little
> bit subtle. The logic to call OmxDecoder::Play() and OmxDecoder::Pause() in
> MediaOmxReader is much clearer. Perhaps we could mimic that logic from
> MediaOmxReader to have a clearer flow.
From my view, it is fine to me and we can refine it later.
It is a little subtle because for now the MediaCodecReader.cpp replace OMXDecoder.cpp and MediaOmxReader.cpp. It plays two roles before.
The only difference in this patch is that |return UNKNOWN_ERROR| if mSource->start() fail.
try server:
https://tbpl.mozilla.org/?tree=Try&rev=eaf9e82c7dfd
Attachment #8475797 -
Attachment is obsolete: true
Attachment #8475797 -
Flags: review?(brsun)
Attachment #8477252 -
Flags: review?(brsun)
| Assignee | ||
Comment 9•11 years ago
|
||
Hi Chirs:
The wip patch tries to avoid the "redundant SetStartTime()" in StateMachine.
The idea is that: stream's mStartTime won't change if we suspend/resume.
So I try to check the |mStartTime == -1| in FinishDecodeMetadata to avoid SetStartTime().
For Rtsp case, the patch can reduce one seek network operation, improve the suspend/resume performance a lot. But for Http streaming case, I guess the patch doens't do any help because the MPEG4Extractor had already rewind the sampletable when we suspend the MediaElement.(I think the http stream still |read the data offset 0| before the seek triggered by resume, once the data is not in the MediaCache, it will trigger an extra download)
How do you think about the startime? We can refine it at another bug, not this one.
Attachment #8478149 -
Flags: feedback?(cpearce)
Comment 10•11 years ago
|
||
Comment on attachment 8478149 [details] [diff] [review]
WIP-StartTime.patch
Review of attachment 8478149 [details] [diff] [review]:
-----------------------------------------------------------------
::: content/media/MediaDecoderStateMachine.cpp
@@ +1918,5 @@
> NS_NewRunnableMethod(this, &MediaDecoderStateMachine::DispatchVideoDecodeTaskIfNeeded));
> VideoQueue().AddPopListener(decodeTask, mDecodeTaskQueue);
> }
>
> if (mScheduler->IsRealTime()) {
I don't understand. I thought for RTSP IsRealTime() should return true? So you won't take the "if (mStartTime != -1)" branch anyway?
Will IsRealTime() not be true for RTSP? If so we can remove all IsRealTime() checks?
I assume we'll take the IsRealTime() branch, and so we'd be better to go:
if (mScheduler->IsRealTime()) {
if (mStartTime == -1) {
// Only set 0 start time if we're not resuming from dormant state.
SetStartTime(0);
}
res = FinishDecodeMetadata();
NS_ENSURE_SUCCESS(res, res);
} else {
// ...
Is that correct? Or is RTSP not real time?
Attachment #8478149 -
Flags: feedback?(cpearce)
Comment 11•11 years ago
|
||
So the only users realtime mode are the RawReader:
http://mxr.mozilla.org/mozilla-central/source/content/media/raw/RawDecoder.cpp#13
And the RTSP reader:
http://mxr.mozilla.org/mozilla-central/source/content/media/omx/RtspOmxDecoder.cpp#21
Though it looks like the RTSP reader may not be realtime? If that is the case, then what you're doing here is probably fine.
| Assignee | ||
Comment 12•11 years ago
|
||
(In reply to Chris Pearce (:cpearce) from comment #10)
>
> I don't understand. I thought for RTSP IsRealTime() should return true? So
> you won't take the "if (mStartTime != -1)" branch anyway?
> Is that correct? Or is RTSP not real time?
RTSP can be realtime or non-realtime.
RTSP realtime: a live stream without duration, non-seekable, usually used for live show.
RTSP non-realtime: a demand stream with fixed duration, like other streaming.
I'll file another bug for the performance issue when suspend/resume.
Comment 13•11 years ago
|
||
Comment on attachment 8478149 [details] [diff] [review]
WIP-StartTime.patch
Review of attachment 8478149 [details] [diff] [review]:
-----------------------------------------------------------------
OK. This is fine then.
Attachment #8478149 -
Flags: feedback+
| Assignee | ||
Comment 14•11 years ago
|
||
r=cpearce.
The try server result looks good at comment 8.
We can check in the patch first then do some improvements at bug 1058429.
Attachment #8477252 -
Attachment is obsolete: true
Attachment #8478149 -
Attachment is obsolete: true
Attachment #8477252 -
Flags: review?(brsun)
Attachment #8478888 -
Flags: review+
| Assignee | ||
Updated•11 years ago
|
Keywords: checkin-needed
Comment 15•11 years ago
|
||
Keywords: checkin-needed
Comment 16•11 years ago
|
||
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Depends on: CVE-2015-4480
| Assignee | ||
Updated•10 years ago
|
No longer depends on: CVE-2015-4480
You need to log in
before you can comment on or make changes to this bug.
Description
•