libstagefright: Fixing a crash in EOS for thumbnail generation.

Initializing an uninitialized variable and fixing
a crash. At EOS OMXCodec::read was returning OK and
a NULL buffer. This is not a valid return combination
as client expects buffer to be non-NULL when there
is no error. With this change OMXCodec::read
will return ERROR_END_OF_STREAM with a NULL buffer
which is a valid return combination. This change
is specific to hardware thumbnail generation.

Conflicts:

	media/libstagefright/OMXCodec.cpp

Change-Id: I83ebdc69e2195b903ea652cb46bf91df48457eec
libstagefright: Software decoder is the first choice for thumbnail generation

Set the flag to use software decoder only for the first call to extract video
thumbnail.

Conflicts:

	media/libstagefright/StagefrightMetadataRetriever.cpp

Change-Id: I547e9d141f03958878f6278d6ac0837460972fce
libstagefright: Enable hardware thumbnail generation

Hardware video decoder will be used to generate
thumbnails if the software decoder fails.

- Enabled for 8660 and 8960
- Add property to disable use of sw decoders for thumbnail creation
- Additional debug logs in metadata retriever

Conflicts:

	include/media/stagefright/OMXCodec.h
	media/libstagefright/OMXCodec.cpp
	media/libstagefright/StagefrightMetadataRetriever.cpp

Change-Id: I249d7be146b5d07468826f28f7843a208ed39c1b
libstagefright: OMXCodec error handling fix

- Drop messages in OMXCodec ERROR state only for s/w OMX component

Change-Id: If9940f1f1429821587938fe005c526ab7559ff8e
libstagefright: Ignoring some events in ERROR state.

Port disable, port enable and flush complete events
need to be ignored if the component is in ERROR
state.

Scenario for port enable:
While the output port is being reconfigured,
component might be parsing input buffers. If
component encounters an error in parsing,
it might move into Invalid state and
then generate a port enable complete on output
port. Adding fix to handle this scenario.

Scenario for port disable:
Port settings disable command complete need to
be ignored in error state. This scenario happens
when the component moves into ERROR state and
issue Port Disable command complete during Port
Reconfiguration.

Scenario for flush:
Component may move into invalid state and then
issue a FlushComplete command. In this case
we should not send any buffers to component
and report error to the client of OMXCodec.

Change-Id: I5385774d77f1a32f6947bb23c7792c0d8e33bda7
frameworks/base/nuplayer: Add logs to capture more debugging information.

- Added property for backing up data buffer to file.

- Changing error message to normal message.
  This is not an error message. The code block executes when end of
  streams reached.

Change-Id: I5bfad7475757360338103d4d7cfcbb534895725a
frameworks/base: Add rendering statistics to Stagefright (Adapted)

- this is an adaptation of change 514 (I88dd988c9) from HC to ICS
- functionality is the same as the forementioned patch
- added all statistics properties for AwesomePlayer into
  Google's Stats struct
- acquire locking before modifying/accessing mStats values
- moved mStatistics check in AwesomePlayer to inside the log functions

Change-Id: I553823b22403a0e5e9fc3998a27a54fec9e1b5c4
libstagefright: Set key mimetype for audio only ASF clips

- Parse function used while scanning the media information is
  not able to get the proper mimetype for ASF clips. Since
  ASF clips are considered as video clips by default based on
  the file extention audio only clips are also visible in
  video application and not in music application.
- Key Mimetype is not updated for ASF clips and retriever
  return mimetype as NULL.
- Check the track information for single track ASF clips and
  set key mimetype to wma for audio only clips so that parse
  function can detect them as audio clips while scanning.

Change-Id: I96857efbd65b77658b4b5ca02c21a2be718d4ab5
CRs-Fixed: 280999
libstagefright: Fix to handle corrupted .m4a clips

- Some m4a clips with corrupted header causes native crash
  in mediaserver.
- This is due to a wrong sample size which had to read from the clip.
- Fixed this by checking for the sample size extracted from the clip
  against the mediabuffer size.

Change-Id: I0e8694c4860f0d32c5aca14e583be8a654f5a98f
CRs-fixed: 298469
libstagefright: Fix to handle corrupted AAC clips

- AAC decoder was returning SUCCESS by default unless
  the state is changed to ERROR.
- For some cases, where the clip is corrupted, it will
  return SUCCESS even though it has not decoded anything.
- Fixed this by initializing the state to -1.

Change-Id: I6eb8ff3cac75435e355680b4e5fe148348d57a16
CRs-Fixed: 284827, 285631
libstagefright: Redesigning ADIF buffer management

- ADIF buffer management logic is redesigned and will take care of the
  issues mentioned below
- ADIF clips, when put on repeat mode fails to play 2nd time onwards
- This is because same decoder object is used in repeat mode.
  So need to clear all the flags and buffer, that are used to store
  info regarding the temp buffer, after clip plays completely in
  ADIF mode.
- When seek was done on ADIF clips, the progress bar was getting stuck
  after seek. This was happening because seek was not acknowledge after
  it was completed, in case when the clips was not seek-able.
- Some ADTS clips were not playing in repeat mode, the reason was that
  some flags were not been reset once the clip finishes playing.
  Resetting the flags resolves the issue.

CRs-Fixed: 321527
CRs-Fixed: 321708
CRs-Fixed: 321728

Conflicts:

	media/libstagefright/codecs/aacdec/SoftAAC.cpp
	media/libstagefright/codecs/aacdec/SoftAAC.h

Change-Id: I4b1fa11a59c71fba91abb1a9f3cc36fff7e763b8
libstagefright: Ignore bad size error when parsing d263 atom.

Change-Id: Id71c6d55181d46671aba3e14bfbc4933687b180f
CRs-Fixed: 288020
Properly identify how much metadata we need to cache in order to instantiate

the extractor without blocking (and therefore be able to abort).

related-to-bug: 5666532

Conflicts:

	media/libstagefright/AwesomePlayer.cpp
	media/libstagefright/MPEG4Extractor.cpp
	media/libstagefright/SampleTable.cpp

Change-Id: Id2acdde897e02baaeabadae70b7c95b66c9041b3
frameworks: base: Added CAF copyright.

Change-Id: I66f88f4ffab2463c8870ce5c3c5ce1fcd87de615
libstagefright: Resolve high bitrate http streaming issues

- Set audio video interleaving offset based on bitrate of the clip
- Start playback if cache is full, useful for very high bitrate clips

CRs-Fixed: 322106

Conflicts:

	media/libstagefright/AwesomePlayer.cpp

Change-Id: I798756eef1bdbf499a086e7f7fcf1d07bf4d4e32
libstagefright : Fix to support FACE and wmf file type

-Add Support for FACE and wmf file type in SniffMPEG4
 function.
-Function returns true if the header contains FACE or
 wmf filetype.

Change-Id: I5cffdc4b7ee8415aa8bb7d1e0f44e2ab9a07ab90
CRs-Fixed: 263296
libstagefright: Disable multi-slicing in mpeg4 video recording.

Multi-slicing is not required for the camcorder use case.
Disables multi-slicing for mpeg4 video encoding in camcorder.

Change-Id: I422cc285af174393de43a2f4905f0e67359df2af
SampleTable: Add shortcut in getMaxSampleSize() to avoid ANR in corrupted clips

-for very large/corrupt values of mNumSampleSizes, getMaxSampleSize will
 run a very long forloop that will cause an ANR
-for cases where mDefaultSampleSize is zero, this ANR issue will not
 occur becase a check is in place for checking mNumSampleSizes corruption
-for cases where mDefaultSampleSize is non-zero, getMaxSampleSize will proceed
 to process each sample for finding max size.  But each run of
 SampleIterator::getSampleSizeDirect will return mDefaultSampleSize as the size
-a check for mDefaultSampleSize being non-zero is placed before the for loop,
 and will return mDefaultSampleSize if it is the case, skipping the entire for loop
 and avoids ANR

Change-Id: Ib2af5f18a2d15fb8efa6e1edaa2e5b46f6746fe8
CRs-Fixed: 316017
libstagefright: Add property to set rate control type

- Add check for property 'encoder.video.rc' to set
  rate control type.
- The value to be set is one of 0..4 with each number
  corresponding to each value in the OMX_VIDEO_CONTROLRATETYPE
  enum.
  0 - ControlRateDisable
  1 - ControlRateVariable
  2 - ControlRateConstant
  3 - ControlRateVariableSkipFrames
  4 - ControlateConstantSkipFrames

Change-Id: I7c9150d346d91e99039fdbb08a441720ac1980c2
CRs-Fixed: 272049
libstagefright: Fix for Noise in Voice call record.

-Using popCount function to get channel count gives incorrect value on
 voice call recording.
-Only STEREO and MONO bits to be considered to count
 channels on input.

Change-Id: I600bcf6c74f89679ae4074b0c16c9120b65a855a