gstreamer--documentation/Resources/use

Source: Internet
Author: User
Tags gstreamer

http://gstreamer.freedesktop.org/src/

Http://gstreamer.freedesktop.org/data/doc/gstreamer/head/qt-gstreamer/html/index.html

There are few tutorials on Qtgstreamer on the internet, so we have to start with the source code. This is my own summary of a small method, generally use these open source libraries, if there is no large company to do maintenance support, often found that the document is not complete. Sometimes even the most basic API can not be found. However, in its source code package will often have a folder called Test or example, there will be some very simple examples. The code for the example is generally shorter, and as long as you understand this example, you can understand what the main API means.


First use Zypper in the Meego to install the good Qtgstreamer (note to update to the meego1.2 version, the previous version did not include Qtgstreamer). View its version information for 0.10.1-1.70. On the GStreamer official website to find the corresponding version of the source code (or directly with Yumdownloader download source code, but it may not be complete), download decompression. The reason to find the same version number is to prevent GStreamer from having API changes in the update.


As expected in the source code to find an example named player and a recoder example. Read the source code, compile, run, feel that the player has been basically able to meet our needs, because it is using GStreamer in the playbin2 to build pipeline, so for the format of support we do not have to think too much. In order to support the complete, out of the zypper himself with the GStreamer plugin, need to own the same version of the FFmpeg plugin package and ugly plugin packaging. Method is also first check the other plugin version of the machine, and then go to GStreamer official website to find the corresponding version, download, compile, install.


As you can see from this example, the method of using Qtgstreamer is simple, first aggregating a qgst::ui::videowidget. This is a qtwidget that can be displayed as a normal component in the Qt interface, on the other hand, it can bind to a common sink, such as the xvideosink on the screen, so that the results of pipeline playback will be displayed in this component, not other windows. From official documents (http://gstreamer.freedesktop.org/data/doc/gstreamer/head/qt-gstreamer/html/classQGst_1_1Ui_1_ 1videowidget.html), you can see that there are two methods of binding,

[CPP]View Plaincopy
    1. void Setvideosink (const elementptr &sink)
    2. void Watchpipeline (const pipelineptr &pipeline)

The corresponding release methods are:

[CPP]View Plaincopy
    1. void     releasevideosink  ()   
    2. void     stoppipelinewatch  ()   

In addition to the player example, there is an example called recorder, the interface is too simple to preview, the use of inconvenience, so to re-write a simple recorder. Recorder pipeline naturally cannot be built with playbin2. The pipeline used in the example are:
Audiosrc! Audioconvert! Audioresample! Audiorate! Speexenc! Queue!
Oggmux! Filesink
Autovideosrc! Ffmpegcolorspace! Theoraenc! Queue!
Due to the need for a preview of the function, we have to do two kinds of structure of the pipeline, a work in preview state, a work in the recording state, when the state switch to change the structure of pipeline.
The pipeline of the preview state are:
Autovideosrc! Queue! Xvimagesink

The recorded pipeline are:

Queue! Xvimagesink
Autovideosrc! Tee!
Queue! Ffmpegcolorspace! Theoraenc! Oggmux! Filesink
You can see that there is no recording, right, not the sound of the tube first. Of course it can be added.

Player's source code in the Qtgstreamer source code example will have, we do not change. The source code for recorder is posted below:

[CPP]View Plaincopy
    1. #include "Recorder.h"
    2. #include <QGst/ElementFactory>
    3. Recorder::recorder (Qwidget *parent)
    4. : Qgst::ui::videowidget (parent)
    5. {
    6. CAMERA_SRC = Qgst::elementfactory::make ("autovideosrc");
    7. Tee = Qgst::elementfactory::make ("Tee");
    8. Queue0 = Qgst::elementfactory::make ("queue");
    9. queue1 = Qgst::elementfactory::make ("queue");
    10. Ffmpegcolorspace = Qgst::elementfactory::make ("Ffmpegcolorspace");
    11. Theoraenc = Qgst::elementfactory::make ("Theoraenc");
    12. Oggmux = Qgst::elementfactory::make ("Oggmux");
    13. Filesink = Qgst::elementfactory::make ("Filesink");
    14. X_sink = Qgst::elementfactory::make ("Xvimagesink");
    15. M_pipeline = qgst::P ipeline::create ();
    16. M_pipeline->add (CAMERA_SRC, tee, Queue0, X_sink, queue1, Ffmpegcolorspace, Theoraenc, Oggmux, Filesink);
    17. Camera_src->link (tee);
    18. Qgst::element::linkmany (Tee, QUEUE0, x_sink);
    19. Qgst::element::linkmany (Tee, queue1, Ffmpegcolorspace, Theoraenc, Oggmux, Filesink);
    20. }
    21. Recorder::~recorder ()
    22. {
    23. if (m_pipeline) {
    24. M_pipeline->setstate (Qgst::statenull);
    25. Releasevideosink ();
    26. }
    27. }
    28. void Recorder::p review ()
    29. {
    30. M_pipeline->setstate (Qgst::statenull);
    31. Releasevideosink ();
    32. M_pipeline->remove (queue1);
    33. M_pipeline->remove (Ffmpegcolorspace);
    34. M_pipeline->remove (THEORAENC);
    35. M_pipeline->remove (OGGMUX);
    36. M_pipeline->remove (Filesink);
    37. Setvideosink (X_sink);
    38. M_pipeline->setstate (qgst::stateplaying);
    39. }
    40. void Recorder::record (const QString &uri)
    41. {
    42. M_pipeline->setstate (Qgst::statenull);
    43. Releasevideosink ();
    44. Filesink->setproperty ("location", URI);
    45. M_pipeline->add (queue1, Ffmpegcolorspace, Theoraenc, Oggmux, Filesink);
    46. //Camera_src->link (TEE);
    47. //Qgst::element::linkmany (tee, QUEUE0, x_sink);
    48. Qgst::element::linkmany (Tee, queue1, Ffmpegcolorspace, Theoraenc, Oggmux, Filesink);
    49. Setvideosink (X_sink);
    50. M_pipeline->setstate (qgst::stateplaying);
    51. }

gstreamer--documentation/Resources/use

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.