Home | History | Annotate | Download | only in android
      1 /*
      2  * Copyright (C) 2011 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #ifndef BUFFERQUEUE_SOURCE_H_
     18 #define BUFFERQUEUE_SOURCE_H_
     19 
     20 #include <media/stagefright/DataSource.h>
     21 
     22 // number of SLuint32 fields to store a buffer event message in an item, by mapping each
     23 //   to the item key (SLuint32), the item size (SLuint32), and the item data (mask on SLuint32)
     24 #define NB_BUFFEREVENT_ITEM_FIELDS 3
     25 
     26 namespace android {
     27 
     28 // a Stagefright DataSource that pulls data from an AndroidBufferQueue
     29 
     30 class BufferQueueSource : public DataSource {
     31 public:
     32 
     33     // store an item structure to indicate a processed buffer
     34     static const SLuint32 kItemProcessed[NB_BUFFEREVENT_ITEM_FIELDS];
     35 
     36     BufferQueueSource(IAndroidBufferQueue *androidBufferQueue);
     37 
     38     virtual status_t initCheck() const;
     39 
     40     virtual ssize_t readAt(off64_t offset, void *data, size_t size);
     41 
     42     virtual status_t getSize(off64_t *size);
     43 
     44     virtual ~BufferQueueSource();
     45 
     46 private:
     47     // the Android Buffer Queue from which data is consumed
     48     IAndroidBufferQueue* const mAndroidBufferQueueSource;
     49 
     50     // a monotonically increasing offset used to translate an offset from the beginning
     51     // of the stream, to an offset in each buffer from the buffer queue source
     52     off64_t mStreamToBqOffset;
     53 
     54     // indicates whether an EOS command has been reached when consuming the buffers in the queue
     55     bool mEosReached;
     56 
     57     BufferQueueSource(const BufferQueueSource &);
     58     BufferQueueSource &operator=(const BufferQueueSource &);
     59 };
     60 
     61 }  // namespace android
     62 
     63 #endif  // BUFFERQUEUE_SOURCE_H_
     64 
     65