frameworks/av: Squashed commit of media features from CAF

 * Completely synced with kk_2.7_rb1.9 branch, as of:

       libmedia: Add QC enhancements to MediaProfiles.

 * Following patch reverted for now, because it doesn't compile:

       frameworks/av: Enable subsystem re-start for LPA/Tunnel

---
MediaProfiles: Add support for camcorder video resolutions.

Added video resolutions to support camcorder recording.
(cherry picked from commit I2291de43ae2be7338c673f2f0417ec5c1581391e)

Change-Id: I309fa41cfa36ee0551a8a7c53072089858a2c66a
(cherry picked from commit 805cb98f40acfb242206b7db71c50bc56ea77d2a)
(cherry picked from commit 68c1f41295f4be54ed13af20ebd1041890d2f3ca)
(cherry picked from commit 5a74f7e0e0fbec707333a1f7481d85961aff3908)

frameworks/av: Add support for FM feature

Add FM handle key and volume key to AudioParamater
class which is used to initimate Audio HAL to
that FM device is connected and apply correct
volume to FM stream

Change-Id: If5fa14faf7946ab27eb42b89546dc2274b24f754
(cherry picked from commit 165f20759433d0137a292b457aa783f801f13277)
(cherry picked from commit c98b484de0877e159f00b3b01d622b6539f0b2bc)
(cherry picked from commit f752d489bb85a94b81d38c72333409b4384d860a)

libstagefright:add enhancements for extended format support

Extended-extractor to support extended container format.
 - Introduce an Extended Extractor to facilitate plugging-in
   of parsers extensions.

Extended-codec to configure codec specific configurations.
 - configures omx component with extensions to augment
   container/codec format-suppor

Extended-utility to add utility methods and shell extensions.
 - Utility methods for supporting following features
  - High Frame Rate (HFR) recording
  - Support for B frame encoding

Change-Id: I77a40af701916f1803fa9c6af3c43a312a8d2c98
(cherry picked from commit ab6a474cd9acc7bc54c54a7c235f6eab032349ca)
(cherry picked from commit fe07c231dbecd255aedbf7aac597260831eb98cf)
(cherry picked from commit df7b013ceeeb4697f448a2d150ae75b86c325013)

libstagefright:enable extended codec/format support

Configure omx component with extended extensions and
register exended-extractor to augment container/codec
support.

Change-Id: I0bfa4bd6c4dfed93a96e1af431018de54d6fb57b
(cherry picked from commit 318c38f40b53e1987473b29a359e586615bf3c02)
(cherry picked from commit 4a0e6d65c200604a9618e2fc90326031153e6f08)
(cherry picked from commit f9b65059fabc1c24ae5107b54f96a017e8fc7376)

libstagefright: For interlace, set decoder in arbitrary mode

In arbitrary mode, frame parsers sends individual fields
to core. Once both the field is decoded, output done (FBD)
is sent back to client.
Default frame by frame mode will send both the fields in
a single buffer to core, which might decode only one field
or will throw up error.

CRs-Fixed: 531034
Change-Id: I31844093b6a93d3a62577fc8d799353d30573c17
(cherry picked from commit cb45f5a702992242538fab6d9e2c36b7b8e55c7f)
(cherry picked from commit 214938ef4f9997233a33a24e9e9e9751a1fa1882)
(cherry picked from commit 646e3bdce1c8241fb46802e7eba3c4f8a528517d)

audio: add support for MSM audio formats

- Add support for EVRC, QCELP, AMRWB+, and WMA formats
- Refernece change If110058284c8b3e18c2f242f560fc7748f62081c form jb-mr2

Change-Id: Ie20f2d61f79d2ba41d552718187b7098141e7b8c
(cherry picked from commit bca561e38853351c0bae15c5d201dbca7f5a027e)
(cherry picked from commit a11972f505000be397ee3a377ec42bf9e5fef420)
(cherry picked from commit 7465e6129b291c66dc7741325a90e3725e40e941)

libstagefright: fix metadata key sizes

 - some wma metadata keys should be treated as 32 bit keys instead
   of 64 bits.
 - fixes wma lossless from failing

Change-Id: Ic6af8392aea6a1bd8810dac59e1d1c27c21c4059
(cherry picked from commit 1fae0bcb8ef9244e1f28d21c36e388ab365e3c0f)
(cherry picked from commit 97be73e3004a838227060f026f38c7231dd7e2f7)
(cherry picked from commit 4d24c91e49c89eadb7b48e47e38a9b7b6df8f1cf)

frameworks/av: Add support for LPA and Tunnel Playback

-Add DirectTrack and DirectTrackClient
-DirectTrack enables client to create a direct
 output
-DirectTrackClient allows notifications to be sent to the
 client from DirectTrack.
-DirectTrack is being used for Low Power Audio
 playback and Tunnel Audio playback
Change-Id: I265ae1fa32c6fdd8be0382cc2b28605bc756a2f3
(cherry picked from commit b255c1963bb3af6f547b68d646737a7c92739555)
(cherry picked from commit 7cb21f77ae28f58da1cb8ba8f684b2968dcd4122)
(cherry picked from commit d4fa9e74c1ee1c2f7f7262c245da0b94dc0ac05b)

frameworks/av: port fixes in LPA and Tunnel mode playback

No History was maintained during porting. Updating the Description
and CR's of all the fixes.
Reference point: AU_LINUX_ANDROID_JB_MR1.04.02.02.049.366
LPA Mode:
LPAPlayer synchronization fixes.
Fixes for seek, pause/resume, EOS handling
Fixes for synchronization b/w the decoder thread, TimedEventQueue and player thread.
Convert mono to stereo for LPA clips - CRs-Fixed: 421639
Add support to change clip duration to enable LPA
Set correct device while creating effects - CRs-Fixed: 496866
Fix the LPA-AudioEffects dead lock issue - CRs-Fixed: 477511
fix volume not updated in pause state of direct track - CRs-Fixed: 490592
Tunnel Mode:
Use tunnel player only for music stream
Exceptions in using Tunnel mode decode - CRs-Fixed: 432080
Enable Tunnel Decode for select formats - CRs-Fixed:437651
Use software decoder for ADTS content. - CRs-fixed: 431096
Skip tunnel mode for playback through AudioCache - CRs-Fixed: 437539
Fix stability crash on tunnel playback. - CRs-Fixed: 498386
support multiple tunnel instances - CRs-Fixed: 483603
Fix ANR repeated next with tunnel clips on BT/AOA - CRs-Fixed: 482966
Update condition to ignore a seek request - CRs-Fixed: 461908
Return seek position until seek has been processed - CRs-Fixed: 454825
TunnelPlayer performance tweaks for audio video playback - CRs-Fixed: 444041
Stability fixes for Tunnel Player (part 2) - CRs-Fixed: 449122
Adjustment for TunnelPlayer buffer size - CRs-Fixed: 447274, 442365
Remove unnecessary code from TunnelPlayer - CRs-Fixed: 442365
update condition to send SEEK_COMPLETE - CRs-Fixed: 441411
Stop extractor source after start in TunnelPlayer - CRs-Fixed: 440239
Handling of EOS, and triggering EOS was wrong in TunnelPlayer.
EOS should not be posted till seek is complete
Disable tunnel mode playback for streaming use cases to avoid jittery playback
CRs-Fixed: 433346 432233 429868
APIs for returning correct timestamps were implemented
Check whether sink is open before flushing or closing it.
Check for mIsAudioRouted is good to know if we are closing it
Seekbar freezes after seek and pause
Check pause status before writing

Change-Id: Iea150f8d75aa9aa6d14da078695e920a3742dd81
(cherry picked from commit f7c9bafa439c5d52d945b966ba08cb16dfc34818)
(cherry picked from commit 68dee8112bbac7e0a70003175ed71b4e6a0376f4)
(cherry picked from commit 19c7fd3e330be551d477e8388b536294b1166a22)

frameworks/av: port fixes in LPA and Tunnel mode playback draft -2

 -LPAPlayer: Update condition to ignore seek CRs-Fixed: 453067
 -libstagefright: TunnelPlayer: update condition to send SEEK_COMPLETE
  CRs-Fixed: 441411
 -libstagefright: Fix ANR with rigorous rewind of 3gp LPA clips
  CRs-Fixed: 491077 490992
 -frameworks/av: Add  metadata mode changes to LPAPlayer
  CRs-Fixed: 458904 491077 490992

Change-Id: Ia89d7d6ac63b1267422a9138df9f98ef59b0ccb7
(cherry picked from commit 72f3bd4cddd3d93812692bffbfc19e2534477938)
(cherry picked from commit db6330d01d91d466d18c7714bd024a10fb009f57)
(cherry picked from commit 416e9ef0eed0ffa7b6e2c9d5a107d1ed2a94a624)

frameworks/av: port fixes in LPA effects

 -audio: fix for deadlock issue during LPA playback.
 -frameworks/av: Fix the LPA-AudioEffects dead lock issue CRs-Fixed: 477511
 -audioflinger: Fix pops in LPA while effects are applied CRs-Fixed: 526799
 -audioflinger: Fix delay in enabling effect for LPA CRs-Fixed: 525510

Change-Id: I92118b5cba17f5337608007052e7dc891d2d6b5b
(cherry picked from commit b24a38903f3fc2fd2bf7cc8fb71d50e1ff38162d)
(cherry picked from commit e8a1d6f80e64822d83f04f4f0704890644048189)
(cherry picked from commit 571f36890abe9f6b8bfe7341776cb5b3975bf952)

frameworks/av: Use the correct macro for AV enhancement

- Use correct macro for AV enhancement
- Add HW aac encoder entry in codec list

Change-Id: I2933ee92ff15875144acec17d3dd8ef61d6b37f9
(cherry picked from commit 5bb728d3bb84f2f24ddfbaa99fa133c87ff66298)
(cherry picked from commit dbc1e5bde1564e80052086a7ee301173515c8d64)
(cherry picked from commit 941f87a69f87dbeab0068f3e9a98c97981ff2700)

libstagefright: Add support for H/W AAC decoder

- Currently, only software AAC decoding is supported.
- Add support for H/W AAC decoding by including it in the
  list of available decoders and use it for decoding only
  if the property 'media.aaccodectype' is set to 0.

Change-Id: I35caba6fb694d17b51a0a9983a5fc5f28cb375ec
CRs-Fixed: 449145
(cherry picked from commit a87c3159a34da86e62c029a06e8e39bef66ae2db)
(cherry picked from commit 6a47c5cb0fe741f31b36bee7e74bd953a3ad3bcc)
(cherry picked from commit 8f6bacb4427d3c84af00b06a8ceb1bb324550acc)

frameworks/av: Compile AudioParameter as shared library

- AudioParameter as shared lib is needed by BT,
  support in WFD source, SRS TruMedia

Change-Id: I30ee584ba7f45f5cafbdf07c45aa7429a84b1b49
(cherry picked from commit 30b89b3bfdafa2f3b877644400efbaefd6572f1e)
(cherry picked from commit 84c3b42f25a28d14426dba29276aae8c5ab795ce)
(cherry picked from commit 53c42631eeb1e13b786d9f4f616f38fe59690e4e)

frameworks/av: Define MSM Audio parameters

- Define MSM audio paramters for FM, VOIP,
  fluence, SSR, and etc.

Change-Id: Iec6f146a0dde3095e3380da439a883b1bbb7d462
(cherry picked from commit 8e943f5bd88bda87f1aa9230487a69372ad49cf7)
(cherry picked from commit 85f4743d12c13aab39ac712a9005632f427c1c43)
(cherry picked from commit 333ba54561c59049f695b07479afe1d5ed734d31)

frameworsk/av: SSR bring-up

- Initial bring up for Surround Sound recording
- 5.1 channel AAC recording and LPCM 5.1 channel
  recording supported

Change-Id: I0d237dc91b74ce6e6550243c9e48cf358734634b
(cherry picked from commit 9f5c9b8eb2f34a0431621b0b54b1b0ea4914224a)
(cherry picked from commit d551917f9e65a0468bd838d4ffbf21006426b4c5)
(cherry picked from commit 236c0861d24eab95f2f6e8941394b38cdd2e15c8)

libmediaplayerservice: Add support for DashPlayer

Add support for DashPlayer in MedaPlayerFactor

Change-Id: I3e1fd871340117cb11975f6819d4bf0e6630607a
(cherry picked from commit f0dcae2a6bf22c8c5846b235f3ae900b8b824f79)
(cherry picked from commit d73fd11ce138f661770e809b959a17dac975b284)
(cherry picked from commit 8d3b0b273ddd2ff08707d33b647d8ee6db3c7598)

frameworks/av: Enable subsystem re-start for LPA/Tunnel

-Audio Daemon in Audio HAL intimates AudioFlinger
 of ADSP status (online/offline) using set_paramaters.
-AudioFlinger send set_parameters to its clients
 which is DirectTrack used for LPA/Tunnel playback.
-In case of ADSP crash during LPA/Tunnel playback,
 clean up of DirectTrack is initiated.

Change-Id: I87f720f305765e00e12032eed3e018aeff952390
(cherry picked from commit 02861e0f092c46640576bb8c700418ed82c266c3)
(cherry picked from commit 5abe97aa9e103420813b87e7abb2b676ffe8d097)
(cherry picked from commit 9a27f1e6c449585095e518f0d2f44e621ef18f52)

frameworks/av: Add support for Quality Of Experience (QOE) events in MediaPlayer

- Add MEDIA_QOE event type
- Allow MEDIA_QOE event to be passed to Application after reset
  is completed, similar to MEDIA_ERROR

Change-Id: I71e3d9e1f5f934c5844d80c65c653b2702a22ca1
(cherry picked from commit a3320b6e617d1143bf2135abfaaff28365513de4)
(cherry picked from commit 3ca9bdff130c204678def4578fc7a06fd8b3a03a)
(cherry picked from commit d13bd4be1a5418cb806029ba65854c13608cbb0c)

frameworks/av: fix for testAACEncoder CTS testcase

- testAACEncoders CTS testcase is failing for
  Hardware aac encoder use case
- hardware encoder has bitrate limitation
  due to which  CTS testcase is failing
- Removed hardware AAC encoder component from MediaCodec list
- Updated the macro for av enhancements in OMXCodec

Change-Id: I3140898f466a600a4488306701aa16e194df8cc6
(cherry picked from commit a084948269982c868916833546c4b56acdeb1de9)
(cherry picked from commit b5cff08f65b0811efec6b739c98b3aa42d1dd3f7)
(cherry picked from commit 96b425ed8125a7f535572276c2efd09ec81a6a59)

audio : init rc to avoid effect's fault state

Effect command doesn't necessarily fill cmd return code into &cmdStatus,
so we should initialize cmdStatus to avoid uninitialized value propagates
to upper stack caller.

Change-Id: I2a2985e3010f0d7b8aedf9244a6faabdf05740ac
CRs-Fixed: 517766

Conflicts:
	services/audioflinger/Effects.cpp
(cherry picked from commit 708dd6e07fc363c76ee9d26a4bc6bb6d7cd3815e)
(cherry picked from commit 0f864db4f4c30c0f31a6998301dd4ec0098a5b24)
(cherry picked from commit 70047618259f68ce74349ed33edffd0ab5a467cc)

audio: Add pause support for hardware omx component

-ADSP doesn't enter sleep state after wma playback is paused
and power suspended.
-No support for NT session pause in case of hardware component.
NT session need to be paused to put ADSP into power collapse.
-Add support of pause in stagefright to ensure device enters
suspend mode. Also add intermediate states to avoid concurrency
issues between read and pause.

Change-Id: Ia0d77a3a0a344b8caad4f4d395641fd6a82f80b9
CRs-Fixed: 496256
(cherry picked from commit 369536f28349e7d1e3033c9d6205c692e32d0751)
(cherry picked from commit 1dcd1d7eba1d82c14961b05dab4e854ed2a979b3)
(cherry picked from commit 0a1b5cbced55d0718d96eccab9e2fe06aa68b199)

audio: Fix for race conditions in direct audio track

-Issue: Mediaserver crash is observed in direct track functions.
-Rootcause: Between write and flush functions, write and destructor
effectpool buffers are accessed without any synchronization that
might lead to operations on null buffers and cause crash.
-Fix: Use mEffectLock to synchronize access of effectpool buffers.

Change-Id: I5982e31fd6d292a9fe28dfee4cf75ebfe0ade5e6
CRs-Fixed: 515107
(cherry picked from commit b14c28f0d3b51ee989640aa46f3addcfabccb6be)
(cherry picked from commit 782f8512023facb1b655fb636bdcbd19af21b493)
(cherry picked from commit 1601287d6a06e11d782a821791bf1f5a9dcbd188)

audio: Correct the condition that checks for wma version

-Few wma clips fail to play when tried to play from music app.
-In overrideComponentName(), a wrong condition is added due to which
component name is always returned null. Due to this all wma clips use
wma component irrespective of the version. This causes playback
failure for other version clips.
-Correct this condition to ensure that all wma clips play fine.

Change-Id: I3a724755fb254bedfc0d3a6dba46c019bc3535bb
CRs-Fixed: 548188
(cherry picked from commit a716cf363b4c7e89fba11547732bbdd9ceff185b)
(cherry picked from commit b7e09e104afb3eda1f2ce95f5ac25fca6483fa28)
(cherry picked from commit bb37a77adbfc6eabbb2c15ea9c7fcae113b6fa9d)

audio: Fix to prevent deadlock in AudioEffects

-Write is blocked waiting for effect chain lock and this causes
decoder thread to wait indefintely.
-Sometimes it is observed that effectschain is locked before
mLPAEffectChain is initialized and but unlocking is skipped if
mLPAEffectChain is initialized in between.Due to this LPA
silence and framework reboot issues are observed as
applyEffectsOn() cannot acquire lock to progress further.
-Use flag to check if all effects have been locked and unlock
accordingly to prevent the deadlock scenario.
CRs-Fixed: 524759

Change-Id: I8ea0b1fc97de157b8254688b5471fd21bc9b565d
(cherry picked from commit 64dda9be5640f02c923cb7d5a08036ebb49ce86f)
(cherry picked from commit 9056fa50895243fbb1672eb117d60004757e7deb)
(cherry picked from commit b43e3b9859ddd90f512c80b637186f2a6e54a835)

audio: check for divide by zero possibilities

When output stream is not available to audioflinger
due to any reason, sampleRate and frameCount have
zero values when trying to create new Audiotrack.
This might result in divide by 0 situation.

Change-Id: If7fbcb6eb4cfcdba6d6bb3b4f758e46e4a57e37b
(cherry picked from commit d1576c1648a78354535fc9cd7130412f300864e5)
(cherry picked from commit 15b951bfcb2180f728669ab23ef0d6791fd790c2)
(cherry picked from commit c980dbea39f984a3c28e2694174e87b311e77308)

audio: Fix crash in flinger during monkey runs

The trackrefptr in DirectTrack descriptor can be invalid and
this can result in a crash is stability runs. Add check for
validity of the trackrefptr before accessing it

Change-Id: I4c7fbff022f381f9d2cdbf0fc04ade8defbb2195
(cherry picked from commit 66917496a28241bf38f117cb05b5810021a185a0)
(cherry picked from commit e1c916bb324f4f6f7923b8e4b2a9c436a65534ff)
(cherry picked from commit dc983d3efd2a5ec3435246d4d2a2e1b4265b5f22)

audio: Use High Quality resampler

Use very high quality resampler to upsample to 48KHz sample
rate.
CRs-fixed: 416730

Change-Id: I30420cbaa8f6d34e2bce408494cc08cb00b175a3
(cherry picked from commit 2904e01dd4a3921b7bc0bec71f63f4757204408b)
(cherry picked from commit 0302cfba74b948e5fb3b2adbcb9330b5dcc36595)
(cherry picked from commit 955a6569ab9d28fbfd6e1e234f06016fcbe5fb6b)

libstagefright: Add interlaced video support

- Adds call to set output buffer size on the native window

Change-Id: I4754e1f1d4d0bba375f719240499ef58c9e87ca2
(cherry picked from commit 63452051ea03bc48af85bd58767fd2a9b0ae13b6)
(cherry picked from commit 856b08a0c452a5d1e0b02487bcbebc44e55fd3e7)
(cherry picked from commit 8f445b519a7c3d107f4180ead01c9722b12b0adf)

ExtendedCodec: Enable timestamp reordering for MPEG4 codec type clips

MPEG4 codec type video clips can contain B frames. This change will
enable timestamp reordering for all MPEG4 codec type clips

CRs-Fixed: 539036

Change-Id: I7682a3781e6aa1b8e73418e4e73ee266c6338770
(cherry picked from commit 8d52ec137be60676c310bda168e8ce18d22dc534)
(cherry picked from commit 3b47eeb2cb5d595f2e755dcaa9e564eac8cbf33d)
(cherry picked from commit 9b47486f507fe834e4c5ab51524be8aa91df875b)

libstagefright: Use proper ctts offset

Calculate ctts offset as difference between composition
time and decoding time, and avoid adding kMaxCttsOffsetTimeUs
as it increases the sample timestamp by the same amount
which leads to av sync loss.

CRs-Fixed: 524739
Change-Id: I75a1bb594536623e3a445af2ee1ceb0cf0926a6e
(cherry picked from commit 863cb2bae6015b32c9ad12f074394c9a54c7bc47)
(cherry picked from commit 8e0e1a4330babf3c38152d48db1f2edf4db7a659)
(cherry picked from commit 87b09615f9473e369883142009d4035e37a2a806)

libvideoeditor: use vWidth and vHeight for buffer allocation

Change-Id: I2ab01b8ef79a3ad9b1eb737b2e9f1211a6e668c2
 - video editor detects crop information from decoder, crop
   width and height will override metadata width and height.
 - decoder is capable of sending crop information where
   crop width and height are smaller than actual resolution.
 - use actual metadata width and height for calculating
   buffer size.
CRs-Fixed: 452511
(cherry picked from commit 93432b8b1c29b2dd62fad923ffa622b002311fa8)
(cherry picked from commit de34cceeb13eead49daf4a47f28bf49286917101)
(cherry picked from commit 865f7b2e0f034b0aea09ef5b13f401c776585bf2)

libstagefright: post video events dynamically - calculate amount of time to delay video event after renderusing the formula: delay = (us between frames)-(us taken by event)-(lateness)

Change-Id: I136ee19520200b26058099f88c8979d1e4e34e23
(cherry picked from commit 61ef39e403f708b014ca434eec35056815558deb)
(cherry picked from commit eb7422fb58a6f95f385574c4d845754db8da6b1f)
(cherry picked from commit 427260792cfa7a53fb27808ac24600a3ebfa7ca2)

libstagefright: Reset the decoder while performing seek

-Observed noise when seeking to beginning of file for the recorded
AMR clip.
-While performing seek, the AMR decoder states are not being reset.
In AMR decoder, the current frame output is predicted using the states
from previous frame. If these states are not cleared, it might cause
noise when seek is performed.
-Fixed by resetting the decoder when seek is issued and port flush
completion is notified to the decoder.

CRs-Fixed: 500851
Change-Id: Ia8480b88521abc09c8b01d6052df4730a0359518
(cherry picked from commit df2b77618d69ac10f1c41ffd5eedb92dd43e161d)
(cherry picked from commit 654f3ad1192bd210b27dbfe29f3cf75a4a3774d8)
(cherry picked from commit 6374b1a4bbf6e853d7214eee6c7177251d246c58)

libstagefright: notify updated stride to NativeWindow for DRC  -Notify updated stride after resolution switch to NativeWindow  to re-interpret the buffer layout  -CRs-fixed: 534910

Change-Id: I4c1427a4826c8d29f93064c34eb3e2eaeef434d7
(cherry picked from commit f93a1ed7561a3a29b73466054e8c43dcbb4c9a1e)
(cherry picked from commit fc948d949de674c4d978b9ca87dea039f4aa86bd)
(cherry picked from commit e5954f19fc67414620ce582a361dd09f5444a01c)

libstagefright: Fix crash in media server mpeg2 playback. -There is a check in dequeueAccessUnitMPEGAudio function inESQueue that  time stamp returned by fetchTimeStamp is alwaysgreater than 0 -In the current scenario, valid time stamp set on the firstframe is  getting replaced in the sub sequent code by -1. -Fix is to reset the flag after first frame is identified CRs-Fixed: 512218

Change-Id: I1be136fb8c8c3a88f46b88f42a1f200582fd1086
(cherry picked from commit 275b8f8d4047346fea7450b97a004c4e43e9a72b)
(cherry picked from commit 2a2bc3622413ac1d0304cffaec9603de77d5228d)
(cherry picked from commit 7836a4a64b3afb56689bc7384cb3dcdaa5a454c0)

frameworks/av: Fix for failure in CTS MediaRecorderTest cases

 -Issue: MediaRecorder CTS test cases are failing.

 -Root Cause: Running the CTS test "testRecorderRandomAction" at beginning
  sets the huge file size and stargeFrightRecorder set the 64 bit file
  offset.
  In MPEG4 writer estimateMoovBoxSize depends on a static const
  variable which uses this file offset info.
  As the variable to calculate estimateMoovBoxSize is static const it
  remains same for next media recording session even if file size is small.

 -Fix: Don't use static const variable which is used to calculate
  estimateMoovBoxSize as its value may change depending on file offsets.

Change-Id: I6bd859fcd7951a4e78abc50bc99dab38e8284877
(cherry picked from commit 0542e6f3af9e17559542764856f430ceaa255cac)
(cherry picked from commit 48fda261ceba7ed1c38c09e3282e9f9147bc03a0)
(cherry picked from commit 70af301150f7a5829f490b44da5caa596da76fa6)

audioflinger: Fix monkey crash in audioflinger set parameter.

-Track ref ptr is initialized to direct track pointer only in create
 Direct Track although the descriptor is created in open Output
-If there is a set parameter coming in during this time it could
 result in a crash as track ref ptr is not initialized.
-Initialize track ref ptr to NULL when descriptor is created.

Change-Id: Iee887baee45a9e7b381f6e2ea2ab523a23689f6b
(cherry picked from commit 10d4ae79b727f7191484f3adda13f9bba9d62c09)
(cherry picked from commit 7d130a825ad58e44b04cce4a4e3f4e4919337a7b)
(cherry picked from commit 0b72bac19b8f8988e385b06ede234ca80e2e2e07)

audio: Adding support for SRS effects

-Add support for SRS Trumedia post processing effects

Change-Id: I41b8983e1a59f5a84e10a21418d7731e6d8ec430
(cherry picked from commit 5b7c47861ce5e4afee2a3ce8e956e0cfec10cf29)
(cherry picked from commit e0ff892f774310e921f9926748ed9a3fe9784af3)
(cherry picked from commit 6d92096966d3dd16f5d08556e3b1273041d1cf58)

audio: Do not apply effect on multichannel content

-Do not apply effect on multichannel content.
-Effects are applied only for mono or stereo.
CRs-Fixed: 484078

Change-Id: I623d40f926d5dd80e74f9aa2f98448158518047e
(cherry picked from commit b11bb5ec8184b0880a37b13033b22e255dbfccac)
(cherry picked from commit af7c6323538ad5b0e5a9f3efd2458cd44744c397)
(cherry picked from commit b984891aaade017a7fc9aad0c0d9f9398653cf71)

audioflinger:Set correct device while creating effects

 -Issue: Effectmodule is created with stale output device
  -Rootcause: While creating effects the output device set is
   output device of mixer thread, which is stale and
   not updated, so effects use the wrong/old device as
   the output device and leads to issue such as difference
   in volume level after setting correct device etc.
  -Fix: Cache the latest device value for direct track
   in a flinger member variable when setparameter of
   flinger is called with new device and
   audioflinger::openoutput is called.
   Use this cached value while creating effects

CRs-Fixed: 496866

Change-Id: I66f08b968c75e8a3b812aad7d91b20fd4557ba24
(cherry picked from commit 20d090b0a481722eede1ca01d38fddcd0977c633)
(cherry picked from commit b39d113f2bac7ca1df8ef144d81bdb28c32975d0)
(cherry picked from commit baf45ef7b6c12a1916d56ce37965de3d366b9f84)

frameworks/av: Initial bringup of voip and vocoders

-Add support for voip and vocoders.

Change-Id: Ibe6dfa100e564e057deebe1613cafd282ee2344e
(cherry picked from commit 96043bb0b5e93099bbbdd2a64c2b6039911c0ac3)
(cherry picked from commit 1682b8eb630c22b7ef0aa7a29746c6ce06118d95)
(cherry picked from commit bf72f4c502777df4703c345d1269057c57d11615)

stagefright: Enable HFR feature during recording video.

- Enable HFR related calls to set HFR mode in stagefright and
  libmediaplayerservice.
CRs-fixed: 557371

Change-Id: I8cf0856b608c5a76a4ac0ad128f05eab43ca4d49
(cherry picked from commit 94a175141e61b8fa20b687ea054a05d15b7746b5)
(cherry picked from commit c57bfc012bd9004ea1ab79d617d55418412bbaaf)
(cherry picked from commit b19127db20c99a23f26adafe105928bca38c4749)

libstagefright: In thumbnail mode set EOS on first frame

- Hardware decoder will only expect I frames, OMXCodec will
set EOS on first ETB to stop more frames from being pulled
- Skip EOS check on FTB so that the first frame will
behandled
- Required for thumbnail generation for some interlaced
videos

Change-Id: I896dec4c58f688a76c29a5d72fb8b61cb04bbfcc
(cherry picked from commit a124c3b722b251f148141b503ba9614cf33af43a)
(cherry picked from commit 44ee9348a2743bf39c2e517612b7e75d7be797ad)
(cherry picked from commit cb113596724882fcd2ce2ee52d1e447698d79865)

audio: Fix a/v sync issue for playback over BT

-Audio and video are out of sync when a video is played/streamed
with a BT headset connected to the target.
-AudioTrack does not consider the BT latency.
-Latency of the BT stream added to the existing latency.

-query for tunnel mode latency
-During tunnel playback, we need to offset latency for audio plaback
 on BT devices by querying BT HAL.

Change-Id: I01a132687aec09cd2897039622daa35cff7ec409
(cherry picked from commit 9096501e28ecb56dc3a5a4d36d474b99804315cd)
(cherry picked from commit 29cb9299834d73a916b7a68617a32fb615c95d95)
(cherry picked from commit ca1f9dd47ca4299797e68029f3c260a5f291d3bd)

audio: AudioTrack constructor initialization

- Initialized few  member variables to null

Change-Id: I36fe9fd2f9e4c2b1967b8d9562ffcad635c6f686
(cherry picked from commit 673fd8919e310f3b2ecea082cfb9c2b08d00ad44)
(cherry picked from commit 75a64de910334e8cb12cfa0079910269e3f4e0e3)

audio: enable tunnel mode based on flags

- Enable tunnel mode playback based on flags defined
  in target board config file instead of checking
  target name.

Change-Id: I78c39b2653e7bae6a6eae8de36fbcacbeb1e6686

Conflicts:
	media/libstagefright/Android.mk
(cherry picked from commit 55a727f33978d374ffbdf612dd4a8560c3bffe3f)
(cherry picked from commit bb7234c9bb0505f3d6df998f84b9a062b206e097)

libstagefright: adjust AV sync late margin based on property

- Current AV late margin is 40 ms
- Read system property media.sf.set.late.margin and if
new AV sync late margin is set then use the same
- Max AV sync late margin allowed is 250 ms
- Min AV sync late margin is default 40 ms

Change-Id: Ie99a4b85264d4a07c983a3f116c18bee3b0acfc7
(cherry picked from commit 0931561dafecce2a0b9148822e77c5f526f31934)
(cherry picked from commit a7fbe5b8ff05c52c902f4f550b812169c8ed456b)

Camcoder: Add missing timelapse recording resolutions to map variable.

VGA and WVGA resolutions were missing in a map variable.
Because of this parsing media profiles xml for these
profiles was crashing.

Change-Id: I5494436f8a3cde9c8a5f0d26b066ca5b37dbd585
CRs-fixed: 564722
(cherry picked from commit 4ac681161652d6dcf6b3313853769b19905010f2)
(cherry picked from commit 668759a8ba976b18932773ad002b7964b9cc071c)

libstagefright: For interlace, set decoder in arbitrary mode

In arbitrary mode, frame parsers sends individual fields
to core. Once both the field is decoded, output done (FBD)
is sent back to client.
Default frame by frame mode will send both the fields in
a single buffer to core, which might decode only one field
or will throw up error.

Change-Id: Ia35d754e685f28f0df9f2c6ef2180b8a3dae1f28
CRs-Fixed: 531034
(cherry picked from commit 0428493caa128cfcb7b3df9082427cb6872a029e)
(cherry picked from commit f0ca79d0509d278a4a322121dc113e173c33534c)

framework\av: libstagefright: Update NOTICE file.

- Update NOTICE file with the correct information.

Change-Id: I04384d4cc12d05db768a41c4580f39050e99441f
CRs-Fixed: 534648
(cherry picked from commit 7edaaf1230953115325b4b2701160d0edd8d63f9)

frameworks/av: rendering statistics for Stagefright.

- this adds extra fps statisticis
- report via dumpsys
- prints statistics before reset at the end of playback ontologcat
- add resume latency, from play_l to render
- add seek latency, from seek_l to render
- enabled using persist.debug.sf.statistics 1
- print all statistics when seek or resume is issued.

Change-Id: I90e215bf3139c38731b9db2b07f6d6f5a916b11e
(cherry picked from commit ecc5a30e06abcf87c941068b44023227e0eb8266)

libmedia: Add QC enhancements to MediaProfiles.

Add entries for:
- 4K resolution support for camcorder
- Timelapse for some resolution

Change-Id: I2bbeec06ac457eb9a6fb92e3aa8fc5ead3372809
(cherry picked from commit 90b4f7c00008b7d1afe4bcc503680e807a935db9)

Revert "frameworks/av: Enable subsystem re-start for LPA/Tunnel"

This reverts commit 9fd40491ae10c99b35c5592e96cc9246b2a8c4ae.

Change-Id: Ia7faba22db4134c36875fec90f98cf23e019288b
frameworks/av: Fixup after squashed commit of CAF media features

 * Fixed makefiles and ifdefs
 * Remarked out one line in MPEG4Extractor.cpp due to compile error

Change-Id: I40a8b12f8ca3fe0f372d68b0e3cf02aa33ffe3c3
frameworks/av: Add ifdefs for QCOM_HARDWARE features

Change-Id: Iebe0da91f0b761bba8eb8c0e181c47bbd0d0703d
frameworks/av: Fix errors from upstream CAF merge

Change-Id: I1d1a515f75366ae8c1989aeea1eed0ef036ce96d