appop: reimplement OP_RECORD_AUDIO op check in mediaserver

Obtain the real package name for the calling app from the packagemanager binder and
link to client registry. Also block only openRecord and createEffect (which are the
methods used to record audio), and ignore the createTrack that is used also by
legacy audio apps and isn't related to audio recording.

Change-Id: Iedd6022fab1efab47a29da7bd07e922dcdeb294c
Signed-off-by: Jorge Ruesga <jorge@ruesga.com>
Merge "appop: reimplement OP_RECORD_AUDIO op check in mediaserver" into cm-11.0
video: Fix crash during video recording

In pause-resume scenario, MPEG4Writer::start is
called to resume recording, which also resets
start time for writer to -1. If this happens
between two tracks updating the writer start
time, it can end up having the larger of the
start time of the two tracks, which results in
crash later due to assert.

Added change to set mStartTimestampUs to -1 only
when writer is being started, and not resuming from
pause.

CRs-Fixed: 692122
Change-Id: Ia98656acfa3912876d01e92b36c5e06a8c84eb7b
StagefrightRecorder: correct the flow of resuming or stopping from pause

1. resume from pause: start the writer first, to avoid frames dropped by
writer due to writer is not started, which caused mosaic frames.

2. stop from pause:  don't start writer, just start encoders and sources,
to avoid unwanted frames are written into clips when stopping in
paused state.

3. recover the pause(dropping frames) in MPEG4Writer.

Change-Id: I4f8f275bce6ac7bc3d4f31f372cc86b362b6c587
CRs-Fixed: 695750 695745
libstagefright: fix issues in AH263Assembler

- if the received rtp packet belongs to the current
  candidate access unit but arrived later, this packet
  still needs to be inserted into this access unit before
  submitting it. Otherwise this incomplete unit would be
  sent to the decoder and cause some potential errors.

- move the functionality for checking the malformed packet
  and calculating the offset of the payload header to one
  function.

Crs-Fixed: 694476
Change-Id: Ie66524ac4b130c443c12bfb007593e5eb4a24019
frameworks/av: miscellaneous fixes

fixes for the following issues reported by KW

5978, 8879, 8880, 8881, 8882, 8883, 8889, 8890,
8892, 8893, 9200, 9201, 10210, 11223, 11224, 18001,
83677, 84525, 5897

Change-Id: I9bb98a07af97cbfc746b21738dfce7cd9e128c94
libstagefright: poke the udp hole twice for future incoming udp packets

- only firing off udp packets once to the source address or the endpoint
  could still be limited in some NAT network environment. As a result,
  client can't receive rtp packets over udp.

- send udp packets to both of the two addresses if they are available.

Change-Id: I7e8a0b36a82bcd85b307c9c15dcfee2bcd7e6030
rtsp: keep some damaged access unit to enhance fault tolerance

Make RTSPSource to accept some damaged access units of H263 to enhance
fault tolerance. Without this patch, damaged access can cause failure of
playback.

Change-Id: I905648f8b30fefa6ec8de18f943ede87641d7300
CRs-Fixed: 687252
Revert "appop: reimplement OP_RECORD_AUDIO op check in mediaserver"

 * This breaks various applications which use the effects API, like
   visualizers.

This reverts commit eb48405109a6a2d2a1d9cb2aaac36e5c71bb5f5b.

Change-Id: I7993aaff67a0aa5f815cc42d3670f3397d7582ac
libstagefright: Decrease reference count before deleting AudioPlayer

-Reference count of AudioSource is not decreased to 1 before deleting
 AudioPlayer, and thus cause the thread blocked in an infinite loop
 due to the AudioSource object is not deleted
-Decrease the strong reference value of AudioSource before
 deleting AudioPlayer

Change-Id: I804211dcca91213c62a4d622baf2001f3cc9955b
CRs-Fixed: 691668
RTSP: Correct the data type in the check

The check for a race condition in RTSP flush has a mismatch
in its data type.
UNKNOWN_ERROR is used as a positive value and isn't equal to
the return value of feedMoreTSData().
Typecast it to fix this mismatch.

Change-Id: Ib8a88af13e5b43f5802052cb8a956c2f391e73b3
HLS: Queue discontinuity only for the first block

If a segment jump happens in HLS, the discontinuity gets
queued for every block read. This leads to continuous decoder
flushes and is observed as a long video freeze.

Changes done to queue the discontinuity only for the first block
after segment jump.

CRs-Fixed: 696452

Change-Id: I79409fe552611fcf3cb6ea9cbc76c8d4f9f5541f
midi audio: allow midi restart even upon stop state

Due to the limitation of EAS_XXX interfaces design, there's no way to
restart midi playback again once last track reaches EOS. To allow this
operation, seek the current track backwards and resume again.

Change-Id: Ib93993eb18e309ac7cb2a305d55ab63f2e86acb9
Merge remote-tracking branch 'cm/cm-11.0' into kk4.4