summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJessica Wagantall <jwagantall@cyngn.com>2016-06-07 10:19:42 -0700
committerJessica Wagantall <jwagantall@cyngn.com>2016-06-07 10:19:42 -0700
commit80c362fec14af5f22e6d3967fc4ea04b363084da (patch)
treefe282db5799ca31479a92451d5f297f80d9529d1 /include
parent8f270dc1ec91d3b34d62202463e0b03939900449 (diff)
parentb57b3967b1a42dd505dbe4fcf1e1d810e3ae3777 (diff)
downloadframeworks_av-80c362fec14af5f22e6d3967fc4ea04b363084da.zip
frameworks_av-80c362fec14af5f22e6d3967fc4ea04b363084da.tar.gz
frameworks_av-80c362fec14af5f22e6d3967fc4ea04b363084da.tar.bz2
Merge tag 'android-6.0.1_r46' into HEAD
Android 6.0.1 release 46 Change-Id: I4fcabf5775aebd2cb8dc0e352d1b1460d3214573
Diffstat (limited to 'include')
-rw-r--r--include/media/stagefright/DataSource.h61
-rw-r--r--include/media/stagefright/OMXCodec.h4
2 files changed, 60 insertions, 5 deletions
diff --git a/include/media/stagefright/DataSource.h b/include/media/stagefright/DataSource.h
index d627fec..c8ad05e 100644
--- a/include/media/stagefright/DataSource.h
+++ b/include/media/stagefright/DataSource.h
@@ -19,7 +19,7 @@
#define DATA_SOURCE_H_
#include <sys/types.h>
-
+#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/MediaErrors.h>
#include <utils/Errors.h>
#include <utils/KeyedVector.h>
@@ -72,6 +72,20 @@ public:
bool getUInt32(off64_t offset, uint32_t *x);
bool getUInt64(off64_t offset, uint64_t *x);
+ // Reads in "count" entries of type T into vector *x.
+ // Returns true if "count" entries can be read.
+ // If fewer than "count" entries can be read, return false. In this case,
+ // the output vector *x will still have those entries that were read. Call
+ // x->size() to obtain the number of entries read.
+ // The optional parameter chunkSize specifies how many entries should be
+ // read from the data source at one time into a temporary buffer. Increasing
+ // chunkSize can improve the performance at the cost of extra memory usage.
+ // The default value for chunkSize is set to read at least 4k bytes at a
+ // time, depending on sizeof(T).
+ template <typename T>
+ bool getVector(off64_t offset, Vector<T>* x, size_t count,
+ size_t chunkSize = (4095 / sizeof(T)) + 1);
+
// May return ERROR_UNSUPPORTED.
virtual status_t getSize(off64_t *size);
@@ -128,6 +142,51 @@ private:
DataSource &operator=(const DataSource &);
};
+template <typename T>
+bool DataSource::getVector(off64_t offset, Vector<T>* x, size_t count,
+ size_t chunkSize)
+{
+ x->clear();
+ if (chunkSize == 0) {
+ return false;
+ }
+ if (count == 0) {
+ return true;
+ }
+
+ T tmp[chunkSize];
+ ssize_t numBytesRead;
+ size_t numBytesPerChunk = chunkSize * sizeof(T);
+ size_t i;
+
+ for (i = 0; i + chunkSize < count; i += chunkSize) {
+ // This loops is executed when more than chunkSize records need to be
+ // read.
+ numBytesRead = this->readAt(offset, (void*)&tmp, numBytesPerChunk);
+ if (numBytesRead == -1) { // If readAt() returns -1, there is an error.
+ return false;
+ }
+ if (numBytesRead < numBytesPerChunk) {
+ // This case is triggered when the stream ends before the whole
+ // chunk is read.
+ x->appendArray(tmp, (size_t)numBytesRead / sizeof(T));
+ return false;
+ }
+ x->appendArray(tmp, chunkSize);
+ offset += numBytesPerChunk;
+ }
+
+ // There are (count - i) more records to read.
+ // Right now, (count - i) <= chunkSize.
+ // We do the same thing as above, but with chunkSize replaced by count - i.
+ numBytesRead = this->readAt(offset, (void*)&tmp, (count - i) * sizeof(T));
+ if (numBytesRead == -1) {
+ return false;
+ }
+ x->appendArray(tmp, (size_t)numBytesRead / sizeof(T));
+ return x->size() == count;
+}
+
} // namespace android
#endif // DATA_SOURCE_H_
diff --git a/include/media/stagefright/OMXCodec.h b/include/media/stagefright/OMXCodec.h
index ea534e0..2f73de8 100644
--- a/include/media/stagefright/OMXCodec.h
+++ b/include/media/stagefright/OMXCodec.h
@@ -40,10 +40,6 @@ struct OMXCodec : public MediaSource,
kPreferSoftwareCodecs = 1,
kIgnoreCodecSpecificData = 2,
- // The client wants to access the output buffer's video
- // data for example for thumbnail extraction.
- kClientNeedsFramebuffer = 4,
-
// Request for software or hardware codecs. If request
// can not be fullfilled, Create() returns NULL.
kSoftwareCodecsOnly = 8,