qtmobility/src/multimedia/qmediaencodersettings.cpp
changeset 14 6fbed849b4f4
parent 11 06b8e2af4411
child 15 1f895d8a5b2b
equal deleted inserted replaced
11:06b8e2af4411 14:6fbed849b4f4
    46 class QAudioEncoderSettingsPrivate  : public QSharedData
    46 class QAudioEncoderSettingsPrivate  : public QSharedData
    47 {
    47 {
    48 public:
    48 public:
    49     QAudioEncoderSettingsPrivate() :
    49     QAudioEncoderSettingsPrivate() :
    50         isNull(true),
    50         isNull(true),
    51         encodingMode(QtMediaServices::ConstantQualityEncoding),
    51         encodingMode(QtMultimedia::ConstantQualityEncoding),
    52         bitrate(-1),
    52         bitrate(-1),
    53         sampleRate(-1),
    53         sampleRate(-1),
    54         channels(-1),
    54         channels(-1),
    55         quality(QtMediaServices::NormalQuality)
    55         quality(QtMultimedia::NormalQuality)
    56     {
    56     {
    57     }
    57     }
    58 
    58 
    59     QAudioEncoderSettingsPrivate(const QAudioEncoderSettingsPrivate &other):
    59     QAudioEncoderSettingsPrivate(const QAudioEncoderSettingsPrivate &other):
    60         QSharedData(other),
    60         QSharedData(other),
    67         quality(other.quality)
    67         quality(other.quality)
    68     {
    68     {
    69     }
    69     }
    70 
    70 
    71     bool isNull;
    71     bool isNull;
    72     QtMediaServices::EncodingMode encodingMode;
    72     QtMultimedia::EncodingMode encodingMode;
    73     QString codec;
    73     QString codec;
    74     int bitrate;
    74     int bitrate;
    75     int sampleRate;
    75     int sampleRate;
    76     int channels;
    76     int channels;
    77     QtMediaServices::EncodingQuality quality;
    77     QtMultimedia::EncodingQuality quality;
    78 
    78 
    79 private:
    79 private:
    80     QAudioEncoderSettingsPrivate& operator=(const QAudioEncoderSettingsPrivate &other);
    80     QAudioEncoderSettingsPrivate& operator=(const QAudioEncoderSettingsPrivate &other);
    81 };
    81 };
    82 
    82 
    86     \brief The QAudioEncoderSettings class provides a set of audio encoder settings.
    86     \brief The QAudioEncoderSettings class provides a set of audio encoder settings.
    87 
    87 
    88     \ingroup multimedia
    88     \ingroup multimedia
    89 
    89 
    90     A audio encoder settings object is used to specify the audio encoder
    90     A audio encoder settings object is used to specify the audio encoder
    91     settings used by QMediaRecorder.  Audio encoder settings are selected
    91     settings used by QMediaRecorder.  Audio encoder settings are selected by
    92     by constructing a QAudioEncoderSettings object, setting the desired
    92     constructing a QAudioEncoderSettings object, setting the desired properties
    93     properties and then passing it to a QMediaRecorder instance using
    93     and then passing it to a QMediaRecorder instance using the
    94     the QMediaRecorder::setEncodingSettings() function.
    94     QMediaRecorder::setEncodingSettings() function.
    95 
    95 
    96     \code
    96     \code
    97     QAudioEncoderSettings audioSettings;
    97     QAudioEncoderSettings audioSettings;
    98     audioSettings.setCodec("audio/mpeg");
    98     audioSettings.setCodec("audio/mpeg");
    99     audioSettings.setChannelCount(2);
    99     audioSettings.setChannelCount(2);
   138     d = other.d;
   138     d = other.d;
   139     return *this;
   139     return *this;
   140 }
   140 }
   141 
   141 
   142 /*!
   142 /*!
   143     Determines if \a other is of equal value to an audio encoder settings object.
   143     Determines if \a other is of equal value to an audio encoder settings
   144 
   144     object.
   145     Returns true if the settings objects are of equal value, and true if they are not of equal
   145 
   146     value.
   146     Returns true if the settings objects are of equal value, and false if they
       
   147     are not of equal value.
   147 */
   148 */
   148 
   149 
   149 bool QAudioEncoderSettings::operator==(const QAudioEncoderSettings &other) const
   150 bool QAudioEncoderSettings::operator==(const QAudioEncoderSettings &other) const
   150 {
   151 {
   151     return (d == other.d) ||
   152     return (d == other.d) ||
   157             d->quality == other.d->quality &&
   158             d->quality == other.d->quality &&
   158             d->codec == other.d->codec);
   159             d->codec == other.d->codec);
   159 }
   160 }
   160 
   161 
   161 /*!
   162 /*!
   162     Determines if \a other is of equal value to an audio encoder settings object.
   163     Determines if \a other is of equal value to an audio encoder settings
   163 
   164     object.
   164     Returns true if the settings objects are not of equal value, and true if they are of equal
   165 
   165     value.
   166     Returns true if the settings objects are not of equal value, and true if
       
   167     they are of equal value.
   166 */
   168 */
   167 
   169 
   168 bool QAudioEncoderSettings::operator!=(const QAudioEncoderSettings &other) const
   170 bool QAudioEncoderSettings::operator!=(const QAudioEncoderSettings &other) const
   169 {
   171 {
   170     return !(*this == other);
   172     return !(*this == other);
   182 }
   184 }
   183 
   185 
   184 /*!
   186 /*!
   185     Returns the audio encoding mode.
   187     Returns the audio encoding mode.
   186 
   188 
   187     \sa QtMediaServices::EncodingMode
   189     \sa QtMultimedia::EncodingMode
   188 */
   190 */
   189 QtMediaServices::EncodingMode QAudioEncoderSettings::encodingMode() const
   191 QtMultimedia::EncodingMode QAudioEncoderSettings::encodingMode() const
   190 {
   192 {
   191     return d->encodingMode;
   193     return d->encodingMode;
   192 }
   194 }
   193 
   195 
   194 /*!
   196 /*!
   195     Sets the audio encoding \a mode setting.
   197     Sets the audio encoding \a mode setting.
   196 
   198 
   197     If QtMediaServices::ConstantQualityEncoding is set,
   199     If QtMultimedia::ConstantQualityEncoding is set, the quality
   198     the quality encoding parameter is used and bit rate is ignored,
   200     encoding parameter is used and bit rate is ignored,
   199     otherwise the bitrate is used.
   201     otherwise the bitrate is used.
   200 
   202 
   201     The audio codec, channels count and sample rate settings
   203     The audio codec, channels count and sample rate settings are used in all
   202     are used in all the encoding modes.
   204     the encoding modes.
   203 
   205 
   204     \sa encodingMode(), QtMediaServices::EncodingMode
   206     \sa encodingMode(), QtMultimedia::EncodingMode
   205 */
   207 */
   206 void QAudioEncoderSettings::setEncodingMode(QtMediaServices::EncodingMode mode)
   208 void QAudioEncoderSettings::setEncodingMode(QtMultimedia::EncodingMode mode)
   207 {
   209 {
   208     d->encodingMode = mode;
   210     d->encodingMode = mode;
   209 }
   211 }
   210 
   212 
   211 /*!
   213 /*!
   242 }
   244 }
   243 
   245 
   244 /*!
   246 /*!
   245     Sets the number of audio \a channels.
   247     Sets the number of audio \a channels.
   246 
   248 
   247     A value of -1 indicates the encoder should make an optimal choice based on what is available
   249     A value of -1 indicates the encoder should make an optimal choice based on
   248     from the audio source and the limitations of the codec.
   250     what is available from the audio source and the limitations of the codec.
   249 */
   251 */
   250 void QAudioEncoderSettings::setChannelCount(int channels)
   252 void QAudioEncoderSettings::setChannelCount(int channels)
   251 {
   253 {
   252     d->isNull = false;
   254     d->isNull = false;
   253     d->channels = channels;
   255     d->channels = channels;
   284 
   286 
   285 /*!
   287 /*!
   286     Returns the audio encoding quality.
   288     Returns the audio encoding quality.
   287 */
   289 */
   288 
   290 
   289 QtMediaServices::EncodingQuality QAudioEncoderSettings::quality() const
   291 QtMultimedia::EncodingQuality QAudioEncoderSettings::quality() const
   290 {
   292 {
   291     return d->quality;
   293     return d->quality;
   292 }
   294 }
   293 
   295 
   294 /*!
   296 /*!
   296 
   298 
   297     Setting the audio quality parameter allows backend to choose the balanced
   299     Setting the audio quality parameter allows backend to choose the balanced
   298     set of encoding parameters to achieve the desired quality level.
   300     set of encoding parameters to achieve the desired quality level.
   299 
   301 
   300     The \a quality settings parameter is only used in the
   302     The \a quality settings parameter is only used in the
   301     \l {QtMediaServices::ConstantQualityEncoding}{constant quality} \l{encodingMode()}{encoding mode}.
   303     \l {QtMultimedia::ConstantQualityEncoding}{constant quality} \l{encodingMode()}{encoding mode}.
   302 */
   304 */
   303 void QAudioEncoderSettings::setQuality(QtMediaServices::EncodingQuality quality)
   305 void QAudioEncoderSettings::setQuality(QtMultimedia::EncodingQuality quality)
   304 {
   306 {
   305     d->isNull = false;
   307     d->isNull = false;
   306     d->quality = quality;
   308     d->quality = quality;
   307 }
   309 }
   308 
   310 
   309 class QVideoEncoderSettingsPrivate  : public QSharedData
   311 class QVideoEncoderSettingsPrivate  : public QSharedData
   310 {
   312 {
   311 public:
   313 public:
   312     QVideoEncoderSettingsPrivate() :
   314     QVideoEncoderSettingsPrivate() :
   313         isNull(true),
   315         isNull(true),
   314         encodingMode(QtMediaServices::ConstantQualityEncoding),
   316         encodingMode(QtMultimedia::ConstantQualityEncoding),
   315         bitrate(-1),
   317         bitrate(-1),
   316         frameRate(0),
   318         frameRate(0),
   317         quality(QtMediaServices::NormalQuality)
   319         quality(QtMultimedia::NormalQuality)
   318     {
   320     {
   319     }
   321     }
   320 
   322 
   321     QVideoEncoderSettingsPrivate(const QVideoEncoderSettingsPrivate &other):
   323     QVideoEncoderSettingsPrivate(const QVideoEncoderSettingsPrivate &other):
   322         QSharedData(other),
   324         QSharedData(other),
   329         quality(other.quality)
   331         quality(other.quality)
   330     {
   332     {
   331     }
   333     }
   332 
   334 
   333     bool isNull;
   335     bool isNull;
   334     QtMediaServices::EncodingMode encodingMode;
   336     QtMultimedia::EncodingMode encodingMode;
   335     QString codec;
   337     QString codec;
   336     int bitrate;
   338     int bitrate;
   337     QSize resolution;
   339     QSize resolution;
   338     qreal frameRate;
   340     qreal frameRate;
   339     QtMediaServices::EncodingQuality quality;
   341     QtMultimedia::EncodingQuality quality;
   340 
   342 
   341 private:
   343 private:
   342     QVideoEncoderSettingsPrivate& operator=(const QVideoEncoderSettingsPrivate &other);
   344     QVideoEncoderSettingsPrivate& operator=(const QVideoEncoderSettingsPrivate &other);
   343 };
   345 };
   344 
   346 
   345 /*!
   347 /*!
   346     \class QVideoEncoderSettings
   348     \class QVideoEncoderSettings
   347     \preliminary
   349     \preliminary
   348     \brief The QVideoEncoderSettings class provides a set of video encoder settings.
   350     \brief The QVideoEncoderSettings class provides a set of video encoder settings.
   349 
   351 
   350     A video encoder settings object is used to specify the video encoder settings used by
   352     A video encoder settings object is used to specify the video encoder
   351     QMediaRecorder.  Video encoder settings are selected by constructing a QVideoEncoderSettings
   353     settings used by QMediaRecorder.  Video encoder settings are selected by
   352     object, setting the desired properties and then passing it to a QMediaRecorder instance using
   354     constructing a QVideoEncoderSettings object, setting the desired properties
   353     the QMediaRecorder::setEncodingSettings() function.
   355     and then passing it to a QMediaRecorder instance using the
       
   356     QMediaRecorder::setEncodingSettings() function.
   354 
   357 
   355     \code
   358     \code
   356     QVideoEncoderSettings videoSettings;
   359     QVideoEncoderSettings videoSettings;
   357     videoSettings.setCodec("video/mpeg2");
   360     videoSettings.setCodec("video/mpeg2");
   358     videoSettings.setResolution(640, 480);
   361     videoSettings.setResolution(640, 480);
   399 }
   402 }
   400 
   403 
   401 /*!
   404 /*!
   402     Determines if \a other is of equal value to a video encoder settings object.
   405     Determines if \a other is of equal value to a video encoder settings object.
   403 
   406 
   404     Returns true if the settings objects are of equal value, and true if they are not of equal
   407     Returns true if the settings objects are of equal value, and false if they
   405     value.
   408     are not of equal value.
   406 */
   409 */
   407 bool QVideoEncoderSettings::operator==(const QVideoEncoderSettings &other) const
   410 bool QVideoEncoderSettings::operator==(const QVideoEncoderSettings &other) const
   408 {
   411 {
   409     return (d == other.d) ||
   412     return (d == other.d) ||
   410            (d->isNull == other.d->isNull &&
   413            (d->isNull == other.d->isNull &&
   417 }
   420 }
   418 
   421 
   419 /*!
   422 /*!
   420     Determines if \a other is of equal value to a video encoder settings object.
   423     Determines if \a other is of equal value to a video encoder settings object.
   421 
   424 
   422     Returns true if the settings objects are not of equal value, and true if they are of equal
   425     Returns true if the settings objects are not of equal value, and false if
   423     value.
   426     they are of equal value.
   424 */
   427 */
   425 bool QVideoEncoderSettings::operator!=(const QVideoEncoderSettings &other) const
   428 bool QVideoEncoderSettings::operator!=(const QVideoEncoderSettings &other) const
   426 {
   429 {
   427     return !(*this == other);
   430     return !(*this == other);
   428 }
   431 }
   438 }
   441 }
   439 
   442 
   440 /*!
   443 /*!
   441     Returns the video encoding mode.
   444     Returns the video encoding mode.
   442 
   445 
   443     \sa QtMediaServices::EncodingMode
   446     \sa QtMultimedia::EncodingMode
   444 */
   447 */
   445 QtMediaServices::EncodingMode QVideoEncoderSettings::encodingMode() const
   448 QtMultimedia::EncodingMode QVideoEncoderSettings::encodingMode() const
   446 {
   449 {
   447     return d->encodingMode;
   450     return d->encodingMode;
   448 }
   451 }
   449 
   452 
   450 /*!
   453 /*!
   451     Sets the video encoding \a mode.
   454     Sets the video encoding \a mode.
   452 
   455 
   453     If QtMediaServices::ConstantQualityEncoding is set,
   456     If QtMultimedia::ConstantQualityEncoding is set,
   454     the quality encoding parameter is used and bit rate is ignored,
   457     the quality encoding parameter is used and bit rate is ignored,
   455     otherwise the bitrate is used.
   458     otherwise the bitrate is used.
   456 
   459 
   457     The rest of encoding settings are respected regardless of encoding mode.
   460     The rest of encoding settings are respected regardless of encoding mode.
   458 
   461 
   459     \sa QtMediaServices::EncodingMode
   462     \sa QtMultimedia::EncodingMode
   460 */
   463 */
   461 void QVideoEncoderSettings::setEncodingMode(QtMediaServices::EncodingMode mode)
   464 void QVideoEncoderSettings::setEncodingMode(QtMultimedia::EncodingMode mode)
   462 {
   465 {
   463     d->isNull = false;
   466     d->isNull = false;
   464     d->encodingMode = mode;
   467     d->encodingMode = mode;
   465 }
   468 }
   466 
   469 
   533 }
   536 }
   534 
   537 
   535 /*!
   538 /*!
   536     Sets the \a resolution of the encoded video.
   539     Sets the \a resolution of the encoded video.
   537 
   540 
   538     An empty QSize indicates the encoder should make an optimal choice based on what is available
   541     An empty QSize indicates the encoder should make an optimal choice based on
   539     from the video source and the limitations of the codec.
   542     what is available from the video source and the limitations of the codec.
   540 */
   543 */
   541 
   544 
   542 void QVideoEncoderSettings::setResolution(const QSize &resolution)
   545 void QVideoEncoderSettings::setResolution(const QSize &resolution)
   543 {
   546 {
   544     d->isNull = false;
   547     d->isNull = false;
   559 
   562 
   560 /*!
   563 /*!
   561     Returns the video encoding quality.
   564     Returns the video encoding quality.
   562 */
   565 */
   563 
   566 
   564 QtMediaServices::EncodingQuality QVideoEncoderSettings::quality() const
   567 QtMultimedia::EncodingQuality QVideoEncoderSettings::quality() const
   565 {
   568 {
   566     return d->quality;
   569     return d->quality;
   567 }
   570 }
   568 
   571 
   569 /*!
   572 /*!
   571 
   574 
   572     Setting the video quality parameter allows backend to choose the balanced
   575     Setting the video quality parameter allows backend to choose the balanced
   573     set of encoding parameters to achieve the desired quality level.
   576     set of encoding parameters to achieve the desired quality level.
   574 
   577 
   575     The \a quality settings parameter is only used in the
   578     The \a quality settings parameter is only used in the
   576     \l {QtMediaServices::ConstantQualityEncoding}{constant quality} \l{encodingMode()}{encoding mode}.
   579     \l {QtMultimedia::ConstantQualityEncoding}{constant quality} \l{encodingMode()}{encoding mode}.
   577 */
   580     The \a quality settings parameter is only used in the \l
   578 
   581     {QtMultimedia::ConstantQualityEncoding}{constant quality}
   579 void QVideoEncoderSettings::setQuality(QtMediaServices::EncodingQuality quality)
   582     \l{encodingMode()}{encoding mode}.
       
   583 */
       
   584 
       
   585 void QVideoEncoderSettings::setQuality(QtMultimedia::EncodingQuality quality)
   580 {
   586 {
   581     d->isNull = false;
   587     d->isNull = false;
   582     d->quality = quality;
   588     d->quality = quality;
   583 }
   589 }
   584 
   590 
   587 class QImageEncoderSettingsPrivate  : public QSharedData
   593 class QImageEncoderSettingsPrivate  : public QSharedData
   588 {
   594 {
   589 public:
   595 public:
   590     QImageEncoderSettingsPrivate() :
   596     QImageEncoderSettingsPrivate() :
   591         isNull(true),
   597         isNull(true),
   592         quality(QtMediaServices::NormalQuality)
   598         quality(QtMultimedia::NormalQuality)
   593     {
   599     {
   594     }
   600     }
   595 
   601 
   596     QImageEncoderSettingsPrivate(const QImageEncoderSettingsPrivate &other):
   602     QImageEncoderSettingsPrivate(const QImageEncoderSettingsPrivate &other):
   597         QSharedData(other),
   603         QSharedData(other),
   603     }
   609     }
   604 
   610 
   605     bool isNull;
   611     bool isNull;
   606     QString codec;
   612     QString codec;
   607     QSize resolution;
   613     QSize resolution;
   608     QtMediaServices::EncodingQuality quality;
   614     QtMultimedia::EncodingQuality quality;
   609 
   615 
   610 private:
   616 private:
   611     QImageEncoderSettingsPrivate& operator=(const QImageEncoderSettingsPrivate &other);
   617     QImageEncoderSettingsPrivate& operator=(const QImageEncoderSettingsPrivate &other);
   612 };
   618 };
   613 
   619 
   614 /*!
   620 /*!
   615     \class QImageEncoderSettings
   621     \class QImageEncoderSettings
   616     \preliminary
   622     \preliminary
   617 
   623 
   618     \brief The QImageEncoderSettings class provides a set of image
   624     \brief The QImageEncoderSettings class provides a set of image encoder
   619     encoder settings.
   625     settings.
   620 
   626 
   621     A image encoder settings object is used to specify the image
   627     A image encoder settings object is used to specify the image encoder
   622     encoder settings used by QStillImageCapture.  Image encoder
   628     settings used by QStillImageCapture.  Image encoder settings are selected
   623     settings are selected by constructing a QImageEncoderSettings
   629     by constructing a QImageEncoderSettings object, setting the desired
   624     object, setting the desired properties and then passing it to a
   630     properties and then passing it to a QStillImageCapture instance using the
   625     QStillImageCapture instance using the
       
   626     QStillImageCapture::setImageSettings() function.
   631     QStillImageCapture::setImageSettings() function.
   627 
   632 
   628     \code
   633     \code
   629     QImageEncoderSettings imageSettings;
   634     QImageEncoderSettings imageSettings;
   630     imageSettings.setCodec("image/jpeg");
   635     imageSettings.setCodec("image/jpeg");
   670     d = other.d;
   675     d = other.d;
   671     return *this;
   676     return *this;
   672 }
   677 }
   673 
   678 
   674 /*!
   679 /*!
   675     Determines if \a other is of equal value to a image encoder settings object.
   680     Determines if \a other is of equal value to a image encoder settings
   676 
   681     object.
   677     Returns true if the settings objects are of equal value, and true if they are not of equal
   682 
   678     value.
   683     Returns true if the settings objects are of equal value, and false if they
       
   684     are not of equal value.
   679 */
   685 */
   680 bool QImageEncoderSettings::operator==(const QImageEncoderSettings &other) const
   686 bool QImageEncoderSettings::operator==(const QImageEncoderSettings &other) const
   681 {
   687 {
   682     return (d == other.d) ||
   688     return (d == other.d) ||
   683            (d->isNull == other.d->isNull &&
   689            (d->isNull == other.d->isNull &&
   686             d->resolution == other.d->resolution);
   692             d->resolution == other.d->resolution);
   687 
   693 
   688 }
   694 }
   689 
   695 
   690 /*!
   696 /*!
   691     Determines if \a other is of equal value to a image encoder settings object.
   697     Determines if \a other is of equal value to a image encoder settings
   692 
   698     object.
   693     Returns true if the settings objects are not of equal value, and true if they are of equal
   699 
   694     value.
   700     Returns true if the settings objects are not of equal value, and false if
       
   701     they are of equal value.
   695 */
   702 */
   696 bool QImageEncoderSettings::operator!=(const QImageEncoderSettings &other) const
   703 bool QImageEncoderSettings::operator!=(const QImageEncoderSettings &other) const
   697 {
   704 {
   698     return !(*this == other);
   705     return !(*this == other);
   699 }
   706 }
   736 }
   743 }
   737 
   744 
   738 /*!
   745 /*!
   739     Sets the \a resolution of the encoded image.
   746     Sets the \a resolution of the encoded image.
   740 
   747 
   741     An empty QSize indicates the encoder should make an optimal choice based on what is available
   748     An empty QSize indicates the encoder should make an optimal choice based on
   742     from the image source and the limitations of the codec.
   749     what is available from the image source and the limitations of the codec.
   743 */
   750 */
   744 
   751 
   745 void QImageEncoderSettings::setResolution(const QSize &resolution)
   752 void QImageEncoderSettings::setResolution(const QSize &resolution)
   746 {
   753 {
   747     d->isNull = false;
   754     d->isNull = false;
   762 
   769 
   763 /*!
   770 /*!
   764     Returns the image encoding quality.
   771     Returns the image encoding quality.
   765 */
   772 */
   766 
   773 
   767 QtMediaServices::EncodingQuality QImageEncoderSettings::quality() const
   774 QtMultimedia::EncodingQuality QImageEncoderSettings::quality() const
   768 {
   775 {
   769     return d->quality;
   776     return d->quality;
   770 }
   777 }
   771 
   778 
   772 /*!
   779 /*!
   773     Sets the image encoding \a quality.
   780     Sets the image encoding \a quality.
   774 */
   781 */
   775 
   782 
   776 void QImageEncoderSettings::setQuality(QtMediaServices::EncodingQuality quality)
   783 void QImageEncoderSettings::setQuality(QtMultimedia::EncodingQuality quality)
   777 {
   784 {
   778     d->isNull = false;
   785     d->isNull = false;
   779     d->quality = quality;
   786     d->quality = quality;
   780 }
   787 }
   781 QT_END_NAMESPACE
   788 QT_END_NAMESPACE