stagefright: OMX.ffmpeg.* are software decoders, ensure they're treated as such

Wherever the component name for OMX.google soft decoders is used to identify
a software-based component, do the same for ffmpeg. Things like memory management
and window buffers care about this.

Change-Id: Ib83561936c7383e8726edb073cea9d78f7d1312f
Set the correct audio bit rate for camera recorded content

Remove the hard coded value for bit rate and replace the value
with the information from meta data.

Change-Id: Ib643c79bbdddaafb3dc703448645606267f7ca4d
libstagefright: Drain input buffer on resume

- Buffers returned from codec in paused state are not drained. When
codec is resumed these buffers are not drained until the next flush,
and may cause timed out issue.
- Added change to drain input buffers for sw decoders when resuming.

Change-Id: Ida2ab1d5dc3a1910accdd6fb89548262a912d8e7
CRs-Fixed: 569585, 574967
Fix kAutoRampDurationUs overflow issue

When kAutoRampDurationUs multiplies with mSampleRate, it overflows to int64.
Type cast it to int64 to make sure RampDurationUs properly.

BUg: 11162491
Change-Id: I4f93bc9acc8456e25623a9255ca7a5b206425009
audio: calculate mute duration using getOutputLatency

-AudioSource mutes for predefined duration
 (kAutoRampStartUs)  at the beginning of a recording.
 Since kAutoRampStartUs is zero, video recording tone
 is also getting recorded in the beggining.

-Fix is to get the output latency of current playback
 stream from audio system to calculate mute duration.

Change-Id: Ib9f4d38fcc8478d148719b70358644c581ba2f25
CRs-fixed: 615511
stagefright: Remove dead code

Change-Id: Ic543dfc5f1278dda1073e607fa9bdb381555256b
stagefright: Fix the input channel count

Change-Id: Ib59e0c9d4ed319a1c23177dcb54dc82d32eb8992
StagefrightRecorder: Pause audio encoder on recorder pause

  When the recorder is paused, OMXCodec-based audio encoders will wait
  for output buffers, timing out after 3 seconds. Pause the audio encoder
  to avoid a timeout error.

CRs-Fixed: 634301
Change-Id: I99b95bf356f87e9c18c763c542cbfcc13bc54fb1
libstagefright: getHFRRatio should return 1 by default

This fixes camera crashes from divide-by-zero. Also, replaced the
workaround introduced in 1b7ac643d2 by a proper fix.

On ENABLE_AV_ENHANCEMENTS path, getHFRRatio returns 1 when 0 is
detected, thus the default value should be 1 not 0. (1 will turn
all multiplication and division into no-op.)

Change-Id: I5020f461011d5903a5d9bea910e11a4af9948e7f
MPEG4Writer: fix mMoovBoxBuffer memory leak

In some cirumstances the writing of the moov box
leaks memory since mMoovBoxBuffer is not freed.

Change-Id: I441360f6c7e84e31fea06067eca98b66b86b54bc
h264_enc: Use free() to release memory allocated with malloc()

mInputFrameData and mSliceGroup are allocated memory with
malloc() but released using delete. Changed this to use free()
instead.

Change-Id: Iecf6684d97fabb2229d9abd94279a24faf9ac2d7
Signed-off-by: Ashok Bhat <ashok.bhat@arm.com>
Skip non I-frames at startup and after seek for RTSP

When seeking or starting an RTSP stream the video might be blurry
until the first I-frame is rendered.
This fix makes sure that the first rendered frame at startup and
after seek is an I-frame (for AVC video).
If an access unit containing SPS information arrives, the decoding
is also started.

Change-Id: I236bd97542f313a3ddcb27c8adf86d25f3f570d8
mediaplayerservice: Untangle legacy callback function

Change-Id: Ie0e3c02a9446a5898ae56453d40a144202de40e3
Fix aac decoder flush

b/8543366

Change-Id: I746ffed6289486b802a2292bfc492ea6c780ed0b
Can't play AAC file with ID3 tag.

When the file is scanned, the ID3 tag is found to have a
footer at the end of audio data. And getAdtsFrameLength
return zero after reading the footer. As a result, the
duration and mInitCheck are not set. The current change
considers the data till footer and sets the duration based
on no. of frames read till the footer/corrupt frame.

Change-Id: Ie8f898435f0d4ca31fdd355146c4db7b37c0b988
Signed-off-by: Arulselvan M <arulselvan.m@intel.com>
Signed-off-by: Jin Wei <wei.a.jin@intel.com>
stagefright: Use HW AAC decoder in ACodec if requested

 * testHLS is failing due to parsing issues with the AAC track
 * Switch to the more robust HW decoder for HLS as well.

Change-Id: I2299266d5f2d8cb0ac457241e4f1d0f4ef87ea05
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 the timescale instead.

CRs-Fixed: 662909
Change-Id: I6b744b4048b7a2d0bb70e2e3a102385a312bf81b
stagefright: remove target specific checks for hfr

and rely on capabilities published in media_profiles
which are guaranteed to be correct for a given target.

CRs-Fixed: 680348
Change-Id: I751031478689b0373674aa7858f4ad79483b990f
HLS: getDuration should return -1 for live streams

According to the MediaPlayer API documentation -1 should
be returned if the duration is not available. But for HLS 0
is returned. Change this.

Change-Id: Ib7704a94ac8dc104ceed4da4491f0d03cb8f4560
Stop thread before deleting object reference

If setPeriodicCapture is called Visualizer will start a thread
and do periodic callbacks. When native_finalize is called the
reference to the class is deleted. If a callback happens after
this the reference is no longer valid and when used from the
callback method the vm crashes. With this patch the thread will
be terminated before deleting the reference.

Change-Id: I30f331437ddad05f8d52c244cdbecb1859a0abd2