qtmobility/src/multimedia/video/qabstractvideobuffer.cpp
changeset 14 6fbed849b4f4
equal deleted inserted replaced
11:06b8e2af4411 14:6fbed849b4f4
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the Qt Mobility Components.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #include "qabstractvideobuffer_p.h"
       
    43 
       
    44 #include <qvariant.h>
       
    45 
       
    46 QT_BEGIN_NAMESPACE
       
    47 
       
    48 /*!
       
    49     \class QAbstractVideoBuffer
       
    50     \brief The QAbstractVideoBuffer class is an abstraction for video data.
       
    51     \since 4.6
       
    52 
       
    53     The QVideoFrame class makes use of a QAbstractVideoBuffer internally to reference a buffer of
       
    54     video data.  Creating a subclass of QAbstractVideoBuffer will allow you to construct video
       
    55     frames from preallocated or static buffers.
       
    56 
       
    57     The contents of a buffer can be accessed by mapping the buffer to memory using the map()
       
    58     function which returns a pointer to memory containing the contents of the the video buffer.
       
    59     The memory returned by map() is released by calling the unmap() function.
       
    60 
       
    61     The handle() of a buffer may also be used to manipulate it's contents using type specific APIs.
       
    62     The type of a buffer's handle is given by the handleType() function.
       
    63 
       
    64     \sa QVideoFrame
       
    65 */
       
    66 
       
    67 /*!
       
    68     \enum QAbstractVideoBuffer::HandleType
       
    69 
       
    70     Identifies the type of a video buffers handle.
       
    71 
       
    72     \value NoHandle The buffer has no handle, its data can only be accessed by mapping the buffer.
       
    73     \value GLTextureHandle The handle of the buffer is an OpenGL texture ID.
       
    74     \value XvShmImageHandle The handle contains pointer to shared memory XVideo image.
       
    75     \value CoreImageHandle The handle contains pointer to Mac OS X CIImage.
       
    76     \value UserHandle Start value for user defined handle types.
       
    77 
       
    78     \sa handleType()
       
    79 */
       
    80 
       
    81 /*!
       
    82     \enum QAbstractVideoBuffer::MapMode
       
    83 
       
    84     Enumerates how a video buffer's data is mapped to memory.
       
    85 
       
    86     \value NotMapped The video buffer has is not mapped to memory.
       
    87     \value ReadOnly The mapped memory is populated with data from the video buffer when mapped, but
       
    88     the content of the mapped memory may be discarded when unmapped.
       
    89     \value WriteOnly The mapped memory in unitialized when mapped, and the content will be used to
       
    90     populate the video buffer when unmapped.
       
    91     \value ReadWrite The mapped memory is populated with data from the video buffer, and the
       
    92     video buffer is repopulated with the content of the mapped memory.
       
    93 
       
    94     \sa mapMode(), map()
       
    95 */
       
    96 
       
    97 /*!
       
    98     Constructs an abstract video buffer of the given \a type.
       
    99 */
       
   100 
       
   101 QAbstractVideoBuffer::QAbstractVideoBuffer(HandleType type)
       
   102     : d_ptr(new QAbstractVideoBufferPrivate)
       
   103 {
       
   104     Q_D(QAbstractVideoBuffer);
       
   105 
       
   106     d->handleType = type;
       
   107 }
       
   108 
       
   109 /*!
       
   110     \internal
       
   111 */
       
   112 
       
   113 QAbstractVideoBuffer::QAbstractVideoBuffer(QAbstractVideoBufferPrivate &dd, HandleType type)
       
   114     : d_ptr(&dd)
       
   115 {
       
   116     Q_D(QAbstractVideoBuffer);
       
   117 
       
   118     d->handleType = type;
       
   119 }
       
   120 
       
   121 /*!
       
   122     Destroys an abstract video buffer.
       
   123 */
       
   124 
       
   125 QAbstractVideoBuffer::~QAbstractVideoBuffer()
       
   126 {
       
   127     delete d_ptr;
       
   128 }
       
   129 
       
   130 /*!
       
   131     Returns the type of a video buffer's handle.
       
   132 
       
   133     \sa handle()
       
   134 */
       
   135 
       
   136 QAbstractVideoBuffer::HandleType QAbstractVideoBuffer::handleType() const
       
   137 {
       
   138     return d_func()->handleType;
       
   139 }
       
   140 
       
   141 /*!
       
   142     \fn QAbstractVideoBuffer::mapMode() const
       
   143 
       
   144     Returns the mode a video buffer is mapped in.
       
   145 
       
   146     \sa map()
       
   147 */
       
   148 
       
   149 /*!
       
   150     \fn QAbstractVideoBuffer::map(MapMode mode, int *numBytes, int *bytesPerLine)
       
   151 
       
   152     Maps the contents of a video buffer to memory.
       
   153 
       
   154     The map \a mode indicates whether the contents of the mapped memory should be read from and/or
       
   155     written to the buffer.  If the map mode includes the QAbstractVideoBuffer::ReadOnly flag the
       
   156     mapped memory will be populated with the content of the video buffer when mapped.  If the map
       
   157     mode includes the QAbstractVideoBuffer::WriteOnly flag the content of the mapped memory will be
       
   158     persisted in the buffer when unmapped.
       
   159 
       
   160     When access to the data is no longer needed be sure to call the unmap() function to release the
       
   161     mapped memory.
       
   162 
       
   163     Returns a pointer to the mapped memory region, or a null pointer if the mapping failed.  The
       
   164     size in bytes of the mapped memory region is returned in \a numBytes, and the line stride in \a
       
   165     bytesPerLine.
       
   166 
       
   167     When access to the data is no longer needed be sure to unmap() the buffer.
       
   168 
       
   169     \note Writing to memory that is mapped as read-only is undefined, and may result in changes
       
   170     to shared data.
       
   171 
       
   172     \sa unmap(), mapMode()
       
   173 */
       
   174 
       
   175 /*!
       
   176     \fn QAbstractVideoBuffer::unmap()
       
   177 
       
   178     Releases the memory mapped by the map() function
       
   179 
       
   180     If the \l {QAbstractVideoBuffer::MapMode}{MapMode} included the QAbstractVideoBuffer::WriteOnly
       
   181     flag this will persist the current content of the mapped memory to the video frame.
       
   182 
       
   183     \sa map()
       
   184 */
       
   185 
       
   186 /*!
       
   187     Returns a type specific handle to the data buffer.
       
   188 
       
   189     The type of the handle is given by handleType() function.
       
   190 
       
   191     \sa handleType()
       
   192 */
       
   193 
       
   194 QVariant QAbstractVideoBuffer::handle() const
       
   195 {
       
   196     return QVariant();
       
   197 }
       
   198 
       
   199 
       
   200 QT_END_NAMESPACE