stagefright: update support for omap3 decoders and encoders

OMAP3 uses 2 decoders, 720P.Decoder and Video.Decoder.

720P.Decoder is proprietary OMAP3 decoder from ITTIAM. Only
one instance of the 720P decoder can run at a time due to memory
restrictions (512MB) and it's quite slow at thumbnail generation
and it's resource hungry.

Video.Decoder is opensource and could support WVGA resolutions.
It only supports baseline profile and max level 31 for AVC, but
could run 4 instances at the same time and is quite fast especially
for watching WhatsApp videos :P

Using the 720P decoder for low resolution videos is not optimal and
trying to use the Video.Decoder for videos other than Baseline profile
will crash the entire DSP and would require a reboot. Currently
stagefright uses codecs in the order they appear in media_codecs.xml
without querying the supported level and profile from the decoder,
due to which wrong codecs are selected causing problems.

Similarly there are 2 encoders, 720P.Encoder and Video.Encoder. They
support different resolutions and should be used selectively.

This patch has been forward ported from Gingerbread branch.

Change-Id: I74f843fe5d28faefa0b51191778ab2ee8c54f5f6
Merge "stagefright: update support for omap3 decoders and encoders" into cm-11.0
libstagefright: mpeg2ts: Ignore continuity_counter discontinuity

The continuity counter is incremented for each ts packet. Any lost
packet results in a discontinuity, and the stock parser flushes the
current frame data leading to corruption if an I-frame is lost.
Avoid flushing on discontinuity to prevent some of this corruption.

CRs-Fixed: 663391

Change-Id: I683269dcb36a1424f6d9a6e543cf9e1ead0103a7
stagefright: Correct timescale in MvHd for HFR

Either timescale or duration must be modified to show the correct
HFR clip duration. Since duration is also queried by the record
timer, modify timescale instead.

CRs-Fixed: 662909
Change-Id: I6b744b4048b7a2d0bb70e2e3a102385a312bf81b
NuPlyer:RTSP: Fix some issues while seeking RTSP source

- Clear the obsolete packets after sending the seek request
- Stop rendering any obsolete frames while seeking
- Stop queueing any obsolete units to source while seeking
- Without this patch, the process-bar will return to
  the previous playback position, and stay at this position
  until the seek operation finish.
  Then, the process-bar will go to the seek position, and go
  forward according the playback of the clips.
- Without this patch, in some platform (based on Q6), seek
  operation will cause several green frame.

CRs-Fixed: 623269
Change-Id: I432de355d8e601a4d434cb78c699043dea2c6b55
NuPlayer: Add RTSP Server Timeout Setting to Meta Data

- Operator requires MoviePlayer to prompt dialog when the activity has been
  paused for longer than server timeout. This patch adds server timeout
  to meta data, so app can get the timeout value.

CRs-Fixed: 638087
Change-Id: I08f98e965497047c420d9d6ecc0b2898abe56369
libstagefright: Customize AV sync behavior

Based on the property, whenever video decoder takes more time
for decoding and causing few consecutive frame drops to maintain
the AV sync, then disable AV sync till it recovers.

This change will avoid freeze whenever any video clips out side
of the supported spec are being played though audio and video
are out of sync.
This improves user experience

Change-Id: Ia4ee899ff2515684259b88f66af216871a7bd38c
stagefright: Add a prefetching source

Add a prefetching source which pre-fetches buffers from
upstream source in a low priority context.
This decouples the caller of read() from the underlying source,
effectively making read() non-blocking as long as there are
already prefetched buffers available.

Change-Id: Ie5338c825dbdab9d88989059204594dc66bb2ac7
libstagefright: Render video frames on vsync

Render video frames on vsync, which helps to
synchronize display and decoder activity, and
reduces power consumption

CRs-Fixed: 649540
Change-Id: I0981d7723621de963d22f7fd7ca0eed48f016090
frameworks/av: Enhance logging for audio usecases

Add/Enable msg logging
-Start and End of playback
-To print file name
-Mode of playback and component used

Change-Id: I2c92d535ab76c9078af39b50fcfde4613f50a581
libstagefright: Print playback stats in suspend call

Print playback statistics in suspend call in AwesomePlayer,
as the video decoder is reset in this call, and playback
statistics are not printed in reset.

Change-Id: If3f74aba1b59cf001c6efa9f6175a6daec0d03d7
CRs-Fixed: 500977
ExtendedCodec: update amrwb+ format parameters

- Add new API to update channel count and
  sample rate of Amrwb+ format.

CRs-Fixed: 631469

Change-Id: I46d2f219a13f3edf49ac0e7a8d098ca96bcd22a2
libstagefright: Avoid MPEG4 DP fallback to software decoder for MSM8x10

-Avoid MPEG4 DP fallback to software decoder for MSM8x10
 Video playback needs to happen with QCOM HW decoder.

Change-Id: I255e1d1c5a6c2508711e4408de0d537e19732b0e
CRs-Fixed: 629449
ExtendedCodec: update amrwb+ component input/output ports

- updated sample rate and channel count of amrwb+ input
  and output configurations

Change-Id: I1a0412ed402e8d58f1db5422c904e18a51fb5965
CRs-Fixed: 631469
libstagefright: Get rtp port range and cache size from system properties

- Operators require setting rtp/rtcp network port range and cache size.
- Parse rtp network port range from persistent system property
  "persist.sys.media.rtp-ports".
- Get cache size from persistent system property
  "persist.sys.media.cache-params", in order to store the value.

Change-Id: Ie044682c422d71f018e509a89a19d976f313e27c
stagefright: Cleanup legacy stuff

Change-Id: Ic87e66939424a23ea589822b4d4e122296d5b20c
libstagefright: Add the conditions to ignore seek and allow sink stop

 -If app issues the multiple seek request to EOF position, player EOS
  gets delayed and app does not move to the next clip.
 -Seek interrupt the sink stop issued at EOF, hence delay in EOS.
 -Do not skip the sink stop if renderer position is EOF and ignore
  seek if seek time is same as player position.

Change-Id: Ic313eabfb738201b6b516555051a7a65c2bf8de2
CRs-Fixed: 667151
libstagefright: Fix for ANR in streaming during seek

In seek, OMXCodec sets state to FLUSHING and if it
gets EOS during seek then the state will remain in
FLUSHING state. OMXCodec stop will happen only in
ERROR, PAUSING and EXECUTING states. Hence solution
is to set mState to EXECUTING after flushing completed

CRs-Fixed: 664381

Change-Id: Ie6f65175ce66ea6973465b68d31e4f82354ea9a9
CameraService: Change order of client declaration and service lock.

Camera service lock has to be acquired after client declaration.
Otherwise, deadlock can occur when client destructor tries to
acquire service lock when its already acquired.

Change-Id: I21757325b3cbfdd5ca52c7becdfaa34ffa5bc768
libmediaplayerservice:Fix deadlock on gapless start failure

Issue:- Current gapless implementation starts the next clip when
MEDIA_PLAYBACK_COMPLETE event for the first clip is recieved
by MediaPlayerService.
-Even if start for next clip fails, application is notified with
MEDIA_INFO_STARTED_AS_NEXT.
- This causes the framework to trigger mediaplayer start which
again fails as it being for the same clip resulting in a deadlock
in the mediaplayer.
Fix:- Notify application with MEDIA_INFO_STARTED_AS_NEXT only when
start for the next clip is successful.

Change-Id: I77c570074c7c98c996122e275161ba88298e56fc