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
Fix for getPosition after seek

When starting playback with a seek pending
(calling seek before start) there is a brief period
when the audioplayer returns an incorrect position (zero)

This is caused by that mSeeking is set to false
before the position in the audioplayer actually is updated.

Change-Id: Iaec355c8fdfe589d9b826d20c2531034f2b4e6fb
Correct the time returned by AudioPlayer::getMediaTime

The change 80a68deec52c9a1b47215ed68526206ec88197f8 was added to
eliminate returning negative media positions.

In the change all negative values of realTimeOffset were discarded.
The value realTimeOffset accounts for the latency and the
number of samples played since last feeding the AudioTrack and is
generally negative. By discarding this value for negative values the
time returned does not account for latency or the number of samples
played.

Change-Id: I470450934228732e34539c227365a225be74ccc8
camera: Disable extra HDR frame on QCOM_HARDWARE

Qualcomm camera HALs default to adding an extra zero-exposure frame
to HDR snapshots; this is breaking third-party apps, and we don't
use it in system-bundled apps, so disable it unless explicitly
requested by the client

Change-Id: Iecb868c5c344d972de7f36dc1bd9cc9fdbabaf4e
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
libstagefright: Adds some parsing capability

o Adds AC3, EAC3 and DTS mime types
o Adds AC3/EAC3 support in MP4 parser
o Adds MPEG4 video, MPEG Audio, AC3, DTS, EAC3 support
in mkv extractor.

Change-Id: I9895c0e40e5ad38976004a9569200f1340d525de
Remove potential cause of underrun.

1. This part of ProcessAudioBuffer function can make underrun issue.
   Because AudioTrackThread::threadLoop's default case is 'pauseInternal'.

2. Without removed part : If AudioTrack obtain small buffer, then it can request small decoded data to player service without waiting.

3. We already have 'waiting codes' in 'AudioTrackshared.cpp ClientProxy::obtainBuffer', it using '__futex_syscall'.
   If we got 'full shared buffer', then 'ClientProxy::obtainBuffer' waits 'ServerProxy::releaseBuffer'.
   It means, there are duplicated 'waiting codes' for ProcessAudioBuffer.

So I removed this part for preventing underrun issue.

Change-Id: Idcca686054d92a4d123873b78b3b9c2e87d3bdca
Signed-off-by: Jinhyuk Seong <jin.seong@lge.com>
Track volume should be maintained even if track is restored.

If track is dead when it set it`s volume is zero, track
sound should be mute even if it is restored. But now, we can hear track sound when it dead.

Change-Id: I79f34c6c7d6f535baba813fd3b8ba8e55cac8ad7
Disconnect the mediaplayer when reset

When the mediaplayer is reset the strong pointer to the
media service client is destroyed and the client should
deconstruct. However this could take some time and if a new
client is connected before the old client is disconnected
there could be problems. By assuring that the client disconnects
these problems can be avoided.

Change-Id: I5d2cf6d22860aa616b14397b1f523ddc35197b83
Solved problem with hanging decode call

Improved error handling in Mediaplayer service,
stops decode from hanging when player->start()
fails.

Change-Id: Ia160ff6eb9aeef0971c004e8baa90750e5636479
Audio streaming error when playing a stream that contains "end of file".

Although EOS is being posted upon receipt of BYE message from RTSP
server, still it didn't reach the media framework and application.
This happens because the Nuplayer::Renderer::onDrainAudioQueue() funtion
returns false after mAudioSink->getPosition() call , and the EOS message
present in mAudioQueue was lost.The mAudioSink->getPosition() returns
NO_INIT as mAudioSink->open() is not yet called,
hence no audio track exists in MediaPlayerService::AudioOutput.

Change-Id: I905e8f3af87dc778952eeef3904c4e2a6a75ca7a
Signed-off-by: Arulselvan M <arulselvan.m@intel.com>
Signed-off-by: Jin Wei <wei.a.jin@intel.com>
AACExtractor: Added support for APE tag

To support aac audio with APE tag we need parse
this tag. Otherwise AACExtractor stops reading of
audio file.

DR: OMAPS00267689

Change-Id: Ic697b90dbc9f2b93aeb227411359c36c113cb71e
Signed-off-by: Daniel Levin <dendy@ti.com>
Audio stops after seeking AVI clip with MP3 audio (special contents without proper key samples)

During seek in AVI, nearest Sync sample was searched both for
audio and video. Sync samples are useful only in case of
video. We can ignore Sync field for non-video tracks.

Change-Id: Ibaeda8f14afb83905e19087625a7d72fb1b3c8d6
Signed-off-by: Arulselvan M <arulselvan.m@intel.com>
Signed-off-by: Jin Wei <wei.a.jin@intel.com>
Support AAC audio (WaveFormat = 0xFF) in AVI container.

Present AVIExtractor doesn't support AAC audio. So some AVI clip with AAC,
AAC-HEv1, AAC-HEv2 audio, can't be played from gallery.
With this fix, added support for AAC audio (WaveFormat = 0xFF) in AVI container.
Also added a condition to check the sampling rates which are supported and return
error if unsupported sampling rate is encountered, to avoid tombstone crash.

Change-Id: Ic8f081ed254ce8c0b3c0cbd1c3811b89b18c6e8e
Signed-off-by: gbhakteX <gurudattax.bhakte@intel.com>
Signed-off-by: Mazhar <mazharx.sameullah@intel.com>
Support MP2 contents in AVI container.

In present code only "Wave Format = 0x55 (MPEG Layer 3)" is supported in AVI container.
With this fix, adding support for "Wave Format = 0x50 (MPEG)".
As per "RFC 2361 - WAVE and AVI Codec Registries":
A.45 MPEG
WAVE form Registration Number (hex): 0x0050
Codec ID in the IANA Namespace:      audio/vnd.wave;codec=50
WAVE form wFormatTag ID:             WAVE_FORMAT_MPEG

Change-Id: I7cc9d3c8bd8da7a079ac8d50a6d61ccbdedb6f82
Signed-off-by: gbhakteX <gurudattax.bhakte@intel.com>
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
Support MPEG4 and H263 FourCC types in Matroska files

Handles MPEG4 and H263 content with FourCC header in Matroska files
based on how these are handled in the AVI parser.

Also adding placehoders for DivX.

Change-Id: I38b2c2fd429b6e4810a7b118bf60823d502320ae
accelerate camera recording start up speed

When do initial buffer submit, if do drainInputBuffers() first, it will always wait all input buffers reached,
and then start fillOutputBuffers().During this time, nothing to do in level codec, all time is cost on waiting,
it is especially severe for Camera recording case, for example, in 30fps case, If 3 input buffers are required,
HW codec will wait at least 99ms to start video encoding, since no outport buffer ready at this
time.

After change call sequence, fillOutputBuffers() is done fast firstly, then do drainInputBuffers(),
when receive one input buffer in HW codec, it can start working immediately, because the working condition is reached,
both input port and out port buffers are ready.

Change-Id: If74fd839f2bb0cae6c7d8ae0912d47abb2cdc045
Signed-off-by: jiguoliang <guoliang.ji@intel.com>
Signed-off-by: ywan171 <yi.a.wang@intel.com>
Support MPEG4 codec in Matroska files

For MPEG4 the matroska parser must handle files with and without
configinfo in the codec private data.

Change-Id: I7025772c87ee24bc074bd3837f6877552245e389
stagefright: Fix playback for mkv files with lacing

Most mkv files having 'lacing' in their audio section to save space.
Android did not handle this properly, sending all frames in the block
with the same time code, which causes stuttery playback.

Change-Id: I4dc76e7c2a53126c7fbdd3628fe7d339d2e3364e