SurfaceMediaSource.h revision 8dcc81a2fdb35905347cf7ef46d198afa7ae79cd
13399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi/*
23399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi * Copyright (C) 2011 The Android Open Source Project
33399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi *
43399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi * Licensed under the Apache License, Version 2.0 (the "License");
53399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi * you may not use this file except in compliance with the License.
63399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi * You may obtain a copy of the License at
73399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi *
83399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi *      http://www.apache.org/licenses/LICENSE-2.0
93399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi *
103399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi * Unless required by applicable law or agreed to in writing, software
113399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi * distributed under the License is distributed on an "AS IS" BASIS,
123399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
133399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi * See the License for the specific language governing permissions and
143399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi * limitations under the License.
153399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi */
163399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi
171a2fafbaa36390a06cc9a066fcbe147c8c47ea77Pannag Sanketi#ifndef ANDROID_GUI_SURFACEMEDIASOURCE_H
181a2fafbaa36390a06cc9a066fcbe147c8c47ea77Pannag Sanketi#define ANDROID_GUI_SURFACEMEDIASOURCE_H
193399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi
208ba01021b573889802e67e029225a96f0dfa471aAndy McFadden#include <gui/IGraphicBufferProducer.h>
21bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam#include <gui/BufferQueue.h>
223399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi
233399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi#include <utils/threads.h>
243399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi#include <utils/Vector.h>
253399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi#include <media/stagefright/MediaSource.h>
263399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi#include <media/stagefright/MediaBuffer.h>
273399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi
283399b7267185646c69b04352211fca4fad9d7547Pannag Sanketinamespace android {
293399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi// ----------------------------------------------------------------------------
303399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi
313399b7267185646c69b04352211fca4fad9d7547Pannag Sanketiclass IGraphicBufferAlloc;
323399b7267185646c69b04352211fca4fad9d7547Pannag Sanketiclass String8;
333399b7267185646c69b04352211fca4fad9d7547Pannag Sanketiclass GraphicBuffer;
343399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi
35bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam// ASSUMPTIONS
36bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam// 1. SurfaceMediaSource is initialized with width*height which
37bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam// can never change.  However, deqeueue buffer does not currently
381a2952aee048ca7b1765e2bc09ebe9aeddaeafa3Mathias Agopian// enforce this as in BufferQueue, dequeue can be used by Surface
39bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam// which can modify the default width and heght.  Also neither the width
40bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam// nor height can be 0.
41bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam// 2. setSynchronousMode is never used (basically no one should call
42bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam// setSynchronousMode(false)
43bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam// 3. setCrop, setTransform, setScalingMode should never be used
44bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam// 4. queueBuffer returns a filled buffer to the SurfaceMediaSource. In addition, a
45bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam// timestamp must be provided for the buffer. The timestamp is in
46bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam// nanoseconds, and must be monotonically increasing. Its other semantics
47bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam// (zero point, etc) are client-dependent and should be documented by the
48bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam// client.
49bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam// 5. Once disconnected, SurfaceMediaSource can be reused (can not
50bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam// connect again)
51bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam// 6. Stop is a hard stop, the last few frames held by the encoder
52bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam// may be dropped.  It is possible to wait for the buffers to be
53bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam// returned (but not implemented)
54bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam
5596fc6cc65ca93009a759a3a874b82a35771b9714Andreas Huber#define DEBUG_PENDING_BUFFERS   0
5696fc6cc65ca93009a759a3a874b82a35771b9714Andreas Huber
57bdddc659a941afdb7f4958f582c6901c07246097Daniel Lamclass SurfaceMediaSource : public MediaSource,
58bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam                                public MediaBufferObserver,
59deeef54487a34034dc0cfaab20b20d557224c07cMathias Agopian                                protected ConsumerListener {
603399b7267185646c69b04352211fca4fad9d7547Pannag Sanketipublic:
61bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam    enum { MIN_UNDEQUEUED_BUFFERS = 4};
623399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi
633399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    struct FrameAvailableListener : public virtual RefBase {
643399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi        // onFrameAvailable() is called from queueBuffer() is the FIFO is
651a2fafbaa36390a06cc9a066fcbe147c8c47ea77Pannag Sanketi        // empty. You can use SurfaceMediaSource::getQueuedCount() to
663399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi        // figure out if there are more frames waiting.
673399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi        // This is called without any lock held can be called concurrently by
683399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi        // multiple threads.
693399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi        virtual void onFrameAvailable() = 0;
703399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    };
713399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi
72bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam    SurfaceMediaSource(uint32_t bufferWidth, uint32_t bufferHeight);
733399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi
741a2fafbaa36390a06cc9a066fcbe147c8c47ea77Pannag Sanketi    virtual ~SurfaceMediaSource();
753399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi
763399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    // For the MediaSource interface for use by StageFrightRecorder:
773399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    virtual status_t start(MetaData *params = NULL);
78a0ead0a2d2ce1d114ad3a17d755dddce831abb40Jamie Gennis    virtual status_t stop();
79a0ead0a2d2ce1d114ad3a17d755dddce831abb40Jamie Gennis    virtual status_t read(MediaBuffer **buffer,
80a0ead0a2d2ce1d114ad3a17d755dddce831abb40Jamie Gennis            const ReadOptions *options = NULL);
813399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    virtual sp<MetaData> getFormat();
823399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi
833399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    // Get / Set the frame rate used for encoding. Default fps = 30
84b33f3407bab0970a7f9241680723a1140b177c50Pannag Sanketi    status_t setFrameRate(int32_t fps) ;
85b33f3407bab0970a7f9241680723a1140b177c50Pannag Sanketi    int32_t getFrameRate( ) const;
863399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi
873399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    // The call for the StageFrightRecorder to tell us that
883399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    // it is done using the MediaBuffer data so that its state
893399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    // can be set to FREE for dequeuing
903399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    virtual void signalBufferReturned(MediaBuffer* buffer);
913399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    // end of MediaSource interface
923399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi
933399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    // getTimestamp retrieves the timestamp associated with the image
94a361483bb5dbd3bbf132c5b99b2df7d197c3fc50Pannag Sanketi    // set by the most recent call to read()
953399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    //
963399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    // The timestamp is in nanoseconds, and is monotonically increasing. Its
973399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    // other semantics (zero point, etc) are source-dependent and should be
983399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    // documented by the source.
993399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    int64_t getTimestamp();
1003399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi
1013399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    // setFrameAvailableListener sets the listener object that will be notified
1023399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    // when a new frame becomes available.
1033399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    void setFrameAvailableListener(const sp<FrameAvailableListener>& listener);
1043399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi
1053399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    // dump our state in a String
1063399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    void dump(String8& result) const;
1073399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    void dump(String8& result, const char* prefix, char* buffer,
1083399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi                                                    size_t SIZE) const;
1093399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi
110b33f3407bab0970a7f9241680723a1140b177c50Pannag Sanketi    // isMetaDataStoredInVideoBuffers tells the encoder whether we will
111b33f3407bab0970a7f9241680723a1140b177c50Pannag Sanketi    // pass metadata through the buffers. Currently, it is force set to true
112b33f3407bab0970a7f9241680723a1140b177c50Pannag Sanketi    bool isMetaDataStoredInVideoBuffers() const;
113b33f3407bab0970a7f9241680723a1140b177c50Pannag Sanketi
114bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam    sp<BufferQueue> getBufferQueue() const { return mBufferQueue; }
115bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam
11666e72bc85fb762876baff60ef29de729da93cf26Andreas Huber    // To be called before start()
11766e72bc85fb762876baff60ef29de729da93cf26Andreas Huber    status_t setMaxAcquiredBufferCount(size_t count);
11866e72bc85fb762876baff60ef29de729da93cf26Andreas Huber
1190868deae404604b577892413c128d55a2bafc56eAndreas Huber    // To be called before start()
1200868deae404604b577892413c128d55a2bafc56eAndreas Huber    status_t setUseAbsoluteTimestamps();
1210868deae404604b577892413c128d55a2bafc56eAndreas Huber
122b33f3407bab0970a7f9241680723a1140b177c50Pannag Sanketiprotected:
1233399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi
124bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam    // Implementation of the BufferQueue::ConsumerListener interface.  These
1251a2952aee048ca7b1765e2bc09ebe9aeddaeafa3Mathias Agopian    // calls are used to notify the Surface of asynchronous events in the
126bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam    // BufferQueue.
127bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam    virtual void onFrameAvailable();
128bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam
129bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam    // Used as a hook to BufferQueue::disconnect()
130bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam    // This is called by the client side when it is done
131bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam    // TODO: Currently, this also sets mStopped to true which
132bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam    // is needed for unblocking the encoder which might be
133bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam    // waiting to read more frames. So if on the client side,
134bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam    // the same thread supplies the frames and also calls stop
135bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam    // on the encoder, the client has to call disconnect before
136bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam    // it calls stop.
137bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam    // In the case of the camera,
138bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam    // that need not be required since the thread supplying the
139bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam    // frames is separate than the one calling stop.
140bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam    virtual void onBuffersReleased();
141bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam
1428dcc81a2fdb35905347cf7ef46d198afa7ae79cdJesse Hall    // SurfaceMediaSource can't handle sideband streams, so this is not expected
1438dcc81a2fdb35905347cf7ef46d198afa7ae79cdJesse Hall    // to ever be called. Does nothing.
1448dcc81a2fdb35905347cf7ef46d198afa7ae79cdJesse Hall    virtual void onSidebandStreamChanged();
1458dcc81a2fdb35905347cf7ef46d198afa7ae79cdJesse Hall
1463399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    static bool isExternalFormat(uint32_t format);
1473399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi
1483399b7267185646c69b04352211fca4fad9d7547Pannag Sanketiprivate:
149bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam    // mBufferQueue is the exchange point between the producer and
150bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam    // this consumer
151bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam    sp<BufferQueue> mBufferQueue;
1523399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi
153d030447b617105b31bf3013e5e4b39d422b53b77Lajos Molnar    struct SlotData {
154d030447b617105b31bf3013e5e4b39d422b53b77Lajos Molnar        sp<GraphicBuffer> mGraphicBuffer;
155d030447b617105b31bf3013e5e4b39d422b53b77Lajos Molnar        uint64_t mFrameNumber;
156d030447b617105b31bf3013e5e4b39d422b53b77Lajos Molnar    };
1573399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi
158d030447b617105b31bf3013e5e4b39d422b53b77Lajos Molnar    // mSlots caches GraphicBuffers and frameNumbers from the buffer queue
159d030447b617105b31bf3013e5e4b39d422b53b77Lajos Molnar    SlotData mSlots[BufferQueue::NUM_BUFFER_SLOTS];
1603399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi
161bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam    // The permenent width and height of SMS buffers
162bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam    int mWidth;
163bdddc659a941afdb7f4958f582c6901c07246097Daniel Lam    int mHeight;
1643399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi
1653399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    // mCurrentSlot is the buffer slot index of the buffer that is currently
1663399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    // being used by buffer consumer
1671a2fafbaa36390a06cc9a066fcbe147c8c47ea77Pannag Sanketi    // (e.g. StageFrightRecorder in the case of SurfaceMediaSource or GLTexture
1681a2952aee048ca7b1765e2bc09ebe9aeddaeafa3Mathias Agopian    // in the case of Surface).
1693399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    // It is initialized to INVALID_BUFFER_SLOT,
1703399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    // indicating that no buffer slot is currently bound to the texture. Note,
1713399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    // however, that a value of INVALID_BUFFER_SLOT does not necessarily mean
1723399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    // that no buffer is bound to the texture. A call to setBufferCount will
1733399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    // reset mCurrentTexture to INVALID_BUFFER_SLOT.
1743399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    int mCurrentSlot;
1753399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi
1762cd25a9056cc150b9fd3ac9b0bca37a1334ffd47Jamie Gennis    // mCurrentBuffers is a list of the graphic buffers that are being used by
1772cd25a9056cc150b9fd3ac9b0bca37a1334ffd47Jamie Gennis    // buffer consumer (i.e. the video encoder). It's possible that these
1782cd25a9056cc150b9fd3ac9b0bca37a1334ffd47Jamie Gennis    // buffers are not associated with any buffer slots, so we must track them
1792cd25a9056cc150b9fd3ac9b0bca37a1334ffd47Jamie Gennis    // separately.  Buffers are added to this list in read, and removed from
1802cd25a9056cc150b9fd3ac9b0bca37a1334ffd47Jamie Gennis    // this list in signalBufferReturned
1812cd25a9056cc150b9fd3ac9b0bca37a1334ffd47Jamie Gennis    Vector<sp<GraphicBuffer> > mCurrentBuffers;
1823399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi
18300f41327264fa2e59cc05abaa5c554b2a32938e1Andreas Huber    size_t mNumPendingBuffers;
18400f41327264fa2e59cc05abaa5c554b2a32938e1Andreas Huber
18596fc6cc65ca93009a759a3a874b82a35771b9714Andreas Huber#if DEBUG_PENDING_BUFFERS
18696fc6cc65ca93009a759a3a874b82a35771b9714Andreas Huber    Vector<MediaBuffer *> mPendingBuffers;
18796fc6cc65ca93009a759a3a874b82a35771b9714Andreas Huber#endif
18896fc6cc65ca93009a759a3a874b82a35771b9714Andreas Huber
1893399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    // mCurrentTimestamp is the timestamp for the current texture. It
1903399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    // gets set to mLastQueuedTimestamp each time updateTexImage is called.
1913399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    int64_t mCurrentTimestamp;
1923399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi
1933399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    // mFrameAvailableListener is the listener object that will be called when a
1943399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    // new frame becomes available. If it is not NULL it will be called from
1953399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    // queueBuffer.
1963399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    sp<FrameAvailableListener> mFrameAvailableListener;
1973399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi
1983399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    // mMutex is the mutex used to prevent concurrent access to the member
1991a2fafbaa36390a06cc9a066fcbe147c8c47ea77Pannag Sanketi    // variables of SurfaceMediaSource objects. It must be locked whenever the
2003399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    // member variables are accessed.
2013399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    mutable Mutex mMutex;
2023399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi
2033399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    ////////////////////////// For MediaSource
2043399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    // Set to a default of 30 fps if not specified by the client side
2053399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    int32_t mFrameRate;
2063399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi
2070e1d71641624c641a0a1abe4098943f5a42c6f94Andreas Huber    // mStarted is a flag to check if the recording is going on
2080e1d71641624c641a0a1abe4098943f5a42c6f94Andreas Huber    bool mStarted;
2090c5c7d2b119d2350c186ae9902919bcf28c3e277Pannag Sanketi
2100c5c7d2b119d2350c186ae9902919bcf28c3e277Pannag Sanketi    // mNumFramesReceived indicates the number of frames recieved from
2110c5c7d2b119d2350c186ae9902919bcf28c3e277Pannag Sanketi    // the client side
2120c5c7d2b119d2350c186ae9902919bcf28c3e277Pannag Sanketi    int mNumFramesReceived;
2130c5c7d2b119d2350c186ae9902919bcf28c3e277Pannag Sanketi    // mNumFramesEncoded indicates the number of frames passed on to the
2140c5c7d2b119d2350c186ae9902919bcf28c3e277Pannag Sanketi    // encoder
2150c5c7d2b119d2350c186ae9902919bcf28c3e277Pannag Sanketi    int mNumFramesEncoded;
2163399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi
217df4a59c61103e7e0e9332e167a0be67da5d82ff3Eino-Ville Talvala    // mFirstFrameTimestamp is the timestamp of the first received frame.
218df4a59c61103e7e0e9332e167a0be67da5d82ff3Eino-Ville Talvala    // It is used to offset the output timestamps so recording starts at time 0.
219df4a59c61103e7e0e9332e167a0be67da5d82ff3Eino-Ville Talvala    int64_t mFirstFrameTimestamp;
220df4a59c61103e7e0e9332e167a0be67da5d82ff3Eino-Ville Talvala    // mStartTimeNs is the start time passed into the source at start, used to
221df4a59c61103e7e0e9332e167a0be67da5d82ff3Eino-Ville Talvala    // offset timestamps.
222df4a59c61103e7e0e9332e167a0be67da5d82ff3Eino-Ville Talvala    int64_t mStartTimeNs;
223df4a59c61103e7e0e9332e167a0be67da5d82ff3Eino-Ville Talvala
22400f41327264fa2e59cc05abaa5c554b2a32938e1Andreas Huber    size_t mMaxAcquiredBufferCount;
22500f41327264fa2e59cc05abaa5c554b2a32938e1Andreas Huber
2260868deae404604b577892413c128d55a2bafc56eAndreas Huber    bool mUseAbsoluteTimestamps;
2270868deae404604b577892413c128d55a2bafc56eAndreas Huber
2283399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    // mFrameAvailableCondition condition used to indicate whether there
2293399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    // is a frame available for dequeuing
2303399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    Condition mFrameAvailableCondition;
2313399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi
23200f41327264fa2e59cc05abaa5c554b2a32938e1Andreas Huber    Condition mMediaBuffersAvailableCondition;
23300f41327264fa2e59cc05abaa5c554b2a32938e1Andreas Huber
2343399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi    // Avoid copying and equating and default constructor
2351a2fafbaa36390a06cc9a066fcbe147c8c47ea77Pannag Sanketi    DISALLOW_IMPLICIT_CONSTRUCTORS(SurfaceMediaSource);
2363399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi};
2373399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi
2383399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi// ----------------------------------------------------------------------------
2393399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi}; // namespace android
2403399b7267185646c69b04352211fca4fad9d7547Pannag Sanketi
2411a2fafbaa36390a06cc9a066fcbe147c8c47ea77Pannag Sanketi#endif // ANDROID_GUI_SURFACEMEDIASOURCE_H
242