MPEG4Extractor: Ignore invalid 'stts' chunk when playing H263 clips for MPEG4Extrator

The sample clips with amr_wb audio track can't be played, because the audio track(amr_wb) contains
more than one `stts` chunks, and the first one is valid with version 0 and flag 0, others are invalid
with error version number and flag. MPEG4Extractor will iterate all the `stts` chunks, once met the
invalid `stts` chunk, the extractor will return error and exist. And return error is too much here, throw
out a warning is just enough.

Change-Id: I8bced6963532f13ed8f5f13af974983466cdfe71
Author: Weian Chen <weian.chen@intel.com>
Signed-off-by: Weian Chen <weian.chen@intel.com>
Singed-off-by: Shuo Gao <shuo.gao@intel.com>
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
Signed-off-by: Jack Ren <jack.ren@intel.com>
Author-tracking-BZ: 48862, 16520
AwesomePlayer: Fix http streaming playback in bad network exit ANR issue

When the network is bad, it may block in request data from the web server. Especially the
AwesomePlayer in prepare status. This may cause reset ANR when awesomeplayer in prepare
status. The fix is to diconnect the mConnectionDataSource to make the blocking calls
return err when reset is called.

Change-Id: Iadedceab72df086cd6b246588a6e273a85230d93
Author: Feng Xiao<fengx.xiao@intel.com>
Signed-off-by: Feng Xiao<fengx.xiao@intel.com>
Signed-off-by: Yi Wang<yi.a.wang@intel.com>
Singed-off-by: Shuo Gao <shuo.gao@intel.com>
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
Signed-off-by: Jack Ren <jack.ren@intel.com>
Author-tracking-BZ: 49390, 22732, 29206
Fixed a 'setVideoSurfaceTexture failed(-22)' after reset.

- The mPlayer is destructed if reference count becomes 0. But native object(MediaPlayerService::Client) is not destructed synchronously.
Native object is disconnected with nativewindow on destructor, But native object's destruction is sometimes deferred about 20ms even if mediaplayer::reset method is called.
If setVideoSurfaceTexture is called before native object's destructor, 'MediaPlayerService: setVideoSurfaceTexture failed: -22' error occured.
In order to prevent this error, native object should be disconnected with nativewindow before the reset method returns.

- Thread-Safe interface pattern(reset_l) does not seem to be usable in this case, so delete it.

- Use a local reference for reducing the range of mutex lock.

Change-Id: I2862e897003704393241d569b9398b23641ce8b9
Signed-off-by: sunjin.lee <sunjin.lee@lge.com>
avcenc: Only do startcode escaping if the next byte requires it

Section 7.4.1 in the H.264 standard says that the only valid bytes
to follow a sequence that starts with 0x000003 are 0x00, 0x01,
0x02 or 0x03.

This makes EncodeDecodeTest pass properly when decoding using
OMX.google.h264.decoder, which is strict about the forbidden
escape sequences.

Change-Id: Ice113d9b934015003ea9cb10d0b21cee4d18d774
NuPlayer: Use a software renderer when using software codecs

This mimics what is done in AwesomePlayer and MediaCodec -
ideally this logic perhaps should be moved into ACodec to
avoid having to replicate it in every caller.

This makes HLS and RTSP playback work in the emulator.

Change-Id: I18027dc3e469889baaae3e1c4afb559de7d0f7d3
avcenc: Prepend startcodes to output buffers

This makes the encoder output data that is similar to what
actual HW encoders output. This form is also what is expected
by virtually every other component - the only exception
seems to be stagefright's MPEG4Writer which happens to work
with this format.

This also makes the encoder's output work in other decoders
when passing through directly. If feeding the encoded data
straight through to a decoder (such as in the EncodeDecodeTest
CTS test), the output from OMX.google.h264.encoder cannot be
decoded by e.g. OMX.Nvidia.h264.decode on a Nexus 7 or
OMX.SEC.avc.dec on a Galaxy S3.

Change-Id: I6e16433a4a66936e3080723c8233681f53bd55e5
MediaCodec: Pass the crop rect to SoftwareRenderer

Change-Id: I434411516eb5fafe9d7aeac9882bbc7f1a8415d8
findSyncSampleNear returns incorrect sample

SampleTable::findSyncSampleNear does not return the closest
sync sample but rather the next one after it.

As a result, for some videos it is not possible to seek backwards
using the rewind button in the player. And the seekbar does
not select the closest point matching the seek operation.

This fix modifies SampleTable::findSyncSampleNear to return
the closest sample.

Change-Id: I11bdc19435004cff904c4b4b7a9ad8af1d7dff83
Avoid jumps to faulty position after seeks

When seeking multiple times it is possible that some seeks
are discarded in AwesomePlayer, which causes unwanted jumps
to faulty positions.
The reason is that a seek flag is reset twice in AwesomePlayer.
At first when the video seek is completed and then again when the
audio seek is completed. If a new seek is made after the previous
video seek completed but before the previous audio seek completed,
the new seek position is discarded by the previous audio seek
completion.

This fix makes sure that the seek flag is reset only when video
has completed the seek.

Change-Id: I8f8741d4cb8682345f1d1855bbad57c05f4e3c8d