├── LICENSE
├── README.md
├── core
├── Anaglyph.cpp
├── Anaglyph.h
├── Audio.cpp
├── Audio.h
├── DelegateControl.cpp
├── DelegateControl.h
├── EventsEmitter.cpp
├── EventsEmitter.h
├── Filters.cpp
├── Filters.h
├── Instance.cpp
├── Instance.h
├── Interface.cpp
├── Interface.h
├── Media.cpp
├── Media.h
├── Mediaplayer.cpp
├── Mediaplayer.h
├── Options.h
├── Player.cpp
├── Player.h
├── Shaders.h
├── Video.cpp
├── Video.h
├── VideoShow.cpp
├── VideoShow.h
├── ViewThread.cpp
├── ViewThread.h
├── filter.h
└── main.cpp
├── forms
└── player.ui
├── logo
├── 1024 Logotype.png
├── 1024 Logotype.svg
├── 144 trprant.svg
├── 144.svg
├── 256 trprant.svg
├── 256.svg
├── 48 trprant.svg
├── 48.svg
├── 512 Logotype.svg
├── 512 trprant.svg
├── 512.svg
├── 72 trprant.svg
├── 72.svg
├── 96 trprant.svg
└── 96.svg
├── player.pro
├── player.pro.user
├── scheme.png
└── widgets
├── ControlPanel.cpp
├── ControlPanel.h
├── VideoSlider.cpp
├── VideoSlider.h
├── VideoWindow.cpp
└── VideoWindow.h
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 SSbug
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | [](https://www.codefactor.io/repository/github/ssbug696/opengl-media-player.-libvlc-and-qt)
6 |
7 | #### Simple and efficient media player(qt,libvlc & c++)
8 | --
9 | ##### What and why?
10 |
11 | ###### Convert YUV rendered on the GPU. High speed video processing. Support for 4K video.
12 | ###### To read the stream using VLC. Converting to GLSL shaders version 2.0.
13 |
14 | ####### Details showed on scheme ( scheme.png )
15 |
16 | The player does not have a design, so the interface is only for testing =)
17 |
18 |
--------------------------------------------------------------------------------
/core/Anaglyph.cpp:
--------------------------------------------------------------------------------
1 | #include "Anaglyph.h"
2 | #include
3 | #include
4 | #include
5 |
6 |
7 | Anaglyph::Anaglyph(float Convergence,
8 | float EyeSeparation,
9 | float AspectRatio,
10 | float FOV,
11 | float NearClippingDistance,
12 | float FarClippingDistance
13 | ){
14 | _flag = 0;
15 | _mConvergence = Convergence;
16 | _mEyeSeparation = EyeSeparation;
17 | _mAspectRatio = AspectRatio;
18 | _mFOV = FOV * 3.14 / 180.0f;
19 | _mNearClippingDistance = NearClippingDistance;
20 | _mFarClippingDistance = FarClippingDistance;
21 | }
22 |
23 |
24 | void Anaglyph::ApplyLeftFrustum() {
25 |
26 | if(_flag & 2) {
27 | top = _ltop;
28 | bottom = _lbottom;
29 | left = _lleft;
30 | right = _lright;
31 | } else {
32 | top = _mNearClippingDistance * tan(_mFOV/2);
33 | bottom = -top;
34 |
35 | float a = _mAspectRatio * tan(_mFOV/2) * _mConvergence;
36 |
37 | float b = a - _mEyeSeparation/2;
38 | float c = a + _mEyeSeparation/2;
39 |
40 | left = -b * _mNearClippingDistance/_mConvergence;
41 | right = c * _mNearClippingDistance/_mConvergence;
42 |
43 | _ltop = top;
44 | _lbottom= bottom;
45 | _lright = right;
46 | _lleft = left;
47 |
48 | _flag++;
49 | }
50 |
51 | // Set the Projection Matrix
52 | glMatrixMode(GL_PROJECTION);
53 | glLoadIdentity();
54 | glFrustum(left, right, bottom, top,
55 | _mNearClippingDistance, _mFarClippingDistance);
56 |
57 | // Displace the world to right
58 | glMatrixMode(GL_MODELVIEW);
59 | glLoadIdentity();
60 | glTranslatef(_mEyeSeparation/2, 0.0f, 0.0f);
61 | }
62 |
63 | void Anaglyph::ApplyRightFrustum()
64 | {
65 | if(_flag & 2) {
66 | top = _rtop;
67 | bottom = _rbottom;
68 | left = _rleft;
69 | right = _rright;
70 | } else {
71 | top = _mNearClippingDistance * tan(_mFOV/2);
72 | bottom = -top;
73 |
74 | float a = _mAspectRatio * tan(_mFOV/2) * _mConvergence;
75 |
76 | float b = a - _mEyeSeparation/2;
77 | float c = a + _mEyeSeparation/2;
78 |
79 | left = -c * _mNearClippingDistance/_mConvergence;
80 | right = b * _mNearClippingDistance/_mConvergence;
81 |
82 | _rtop = top;
83 | _rbottom= bottom;
84 | _rright = right;
85 | _rleft = left;
86 |
87 | _flag++;
88 | }
89 |
90 | glMatrixMode(GL_PROJECTION);
91 | glLoadIdentity();
92 | glFrustum(left, right, bottom, top,
93 | _mNearClippingDistance, _mFarClippingDistance);
94 |
95 | glMatrixMode(GL_MODELVIEW);
96 | glLoadIdentity();
97 | glTranslatef(-_mEyeSeparation/2, 0.0f, 0.0f);
98 | }
99 |
--------------------------------------------------------------------------------
/core/Anaglyph.h:
--------------------------------------------------------------------------------
1 | #ifndef ANAGLYPH_H
2 | #define ANAGLYPH_H
3 |
4 |
5 | class Anaglyph {
6 | public:
7 | Anaglyph(float, float, float, float, float, float);
8 | void ApplyLeftFrustum();
9 | void ApplyRightFrustum();
10 |
11 | private:
12 | float _mConvergence;
13 | float _mEyeSeparation;
14 | float _mAspectRatio;
15 | float _mFOV;
16 | float _mNearClippingDistance;
17 | float _mFarClippingDistance;
18 |
19 | float _rtop, _rbottom, _rleft, _rright,
20 | _ltop, _lbottom, _lleft, _lright;
21 |
22 | float top, bottom, left, right;
23 |
24 | short _flag;
25 | };
26 |
27 | #endif // ANAGLYPH_H
28 |
--------------------------------------------------------------------------------
/core/Audio.cpp:
--------------------------------------------------------------------------------
1 | #include "vlc/vlc.h"
2 | #include "Audio.h"
3 | #include "Mediaplayer.h"
4 |
5 |
6 | Audio::Audio(libvlc_media_player_t * player)
7 | {
8 | mp = player;
9 | }
10 |
11 | Audio::~Audio(){
12 | delete mp;
13 | }
14 |
15 | bool Audio::getMute() const {
16 | bool mute = false;
17 | if (mp) {
18 | mute = libvlc_audio_get_mute(mp);
19 | }
20 | return mute;
21 | }
22 |
23 | void Audio::setVolume(int volume){
24 | if (mp) {
25 | if (volume != getVolume()) {
26 | libvlc_audio_set_volume(mp, volume);
27 | }
28 | }
29 | }
30 |
31 | bool Audio::toogleMute() const{
32 | if (mp) {
33 | libvlc_audio_toggle_mute(mp);
34 | }
35 | return getMute();
36 | }
37 |
38 | int Audio::getVolume(){
39 | int volume = -1;
40 | if (mp) {
41 | volume = libvlc_audio_get_volume(mp);
42 | }
43 |
44 | return volume;
45 | }
46 |
--------------------------------------------------------------------------------
/core/Audio.h:
--------------------------------------------------------------------------------
1 | #ifndef AUDIO_H
2 | #define AUDIO_H
3 | #include
4 |
5 |
6 | class MediaPlayer;
7 |
8 | struct libvlc_media_player_t;
9 | /*!
10 | * \brief The Audio class
11 | */
12 | class Audio {
13 | public:
14 | Audio(libvlc_media_player_t *);
15 | ~Audio();
16 | bool getMute() const;
17 | bool toogleMute() const;
18 | void setVolume(int volume);
19 | int getVolume();
20 |
21 | private:
22 | libvlc_media_player_t * mp;
23 | };
24 |
25 | #endif // AUDIO_H
26 |
--------------------------------------------------------------------------------
/core/DelegateControl.cpp:
--------------------------------------------------------------------------------
1 | #include "DelegateControl.h"
2 | #include "Mediaplayer.h"
3 |
4 |
5 | DelegateControl::DelegateControl(Mediaplayer * mp){
6 | _mp = mp;
7 | }
8 |
9 |
10 | void DelegateControl::play(){
11 | //_mp->play();
12 | }
13 |
14 |
15 | void DelegateControl::pause(){
16 | //_mp->pause();
17 | }
18 |
19 |
--------------------------------------------------------------------------------
/core/DelegateControl.h:
--------------------------------------------------------------------------------
1 | #ifndef DELEGATECONTROL_H
2 | #define DELEGATECONTROL_H
3 | #include
4 |
5 | struct libvlc_event_t;
6 | struct libvlc_event_manager_t;
7 | struct libvlc_media_t;
8 | struct libvlc_media_player_t;
9 | struct Mediaplayer;
10 |
11 |
12 | class DelegateControl : public QObject {
13 | Q_OBJECT
14 | public:
15 | // explicit DelegateControl(QObject *parent = 0);
16 | DelegateControl(Mediaplayer *);
17 |
18 | void play();
19 | void pause();
20 | Mediaplayer * _mp;
21 |
22 | signals:
23 |
24 | public slots:
25 | };
26 |
27 | #endif // DELEGATECONTROL_H
28 |
--------------------------------------------------------------------------------
/core/EventsEmitter.cpp:
--------------------------------------------------------------------------------
1 | #include "EventsEmitter.h"
2 | #include "Mediaplayer.h"
3 | #include
4 | #include
5 | #include
6 |
7 |
8 | void callbackEvents(const libvlc_event_t *, void *);
9 | EventsEmitter * e_emitter;
10 |
11 | EventsEmitter::EventsEmitter(QObject *parent) : QObject(parent)
12 | {}
13 |
14 |
15 | EventsEmitter::EventsEmitter(Interface * interface) {
16 | _interface = interface;
17 | e_emitter = this;
18 | events = libvlc_media_player_event_manager(_interface->ptrP->mediaPlayer->getInstance());
19 | bindEvents();
20 | }
21 |
22 |
23 | void EventsEmitter::bindEvents() {
24 | this->connect(this, SIGNAL(Playing()), _interface, SLOT(updateStatusControlPanel()));
25 | QList list;
26 | list << libvlc_MediaPlayerMediaChanged
27 | << libvlc_MediaPlayerNothingSpecial
28 | << libvlc_MediaPlayerOpening
29 | << libvlc_MediaPlayerBuffering
30 | << libvlc_MediaPlayerPlaying
31 | << libvlc_MediaPlayerPaused
32 | << libvlc_MediaPlayerStopped
33 | << libvlc_MediaPlayerForward
34 | << libvlc_MediaPlayerBackward
35 | << libvlc_MediaPlayerEndReached
36 | << libvlc_MediaPlayerEncounteredError
37 | << libvlc_MediaPlayerTimeChanged
38 | << libvlc_MediaPlayerPositionChanged
39 | << libvlc_MediaPlayerSeekableChanged
40 | << libvlc_MediaPlayerPausableChanged
41 | << libvlc_MediaPlayerTitleChanged
42 | << libvlc_MediaPlayerSnapshotTaken
43 | << libvlc_MediaPlayerLengthChanged
44 | << libvlc_MediaPlayerVout;
45 |
46 | foreach(const libvlc_event_e &event, list) {
47 | libvlc_event_attach(events, event, &callbackEvents, this);
48 | }
49 | // libvlc_event_attach(events, libvlc_MediaPlayerSnapshotTaken, &callbackEvents, this);
50 | }
51 |
52 |
53 | void EventsEmitter::unbindEvents(){}
54 |
55 |
56 | void EventsEmitter::Vout(){
57 | _interface->outFinishedEvent();
58 | }
59 |
60 | void EventsEmitter::PositionChanged(){
61 | std::cout << "PositionChanged event \n" << std::endl;
62 | }
63 |
64 | void EventsEmitter::Buffering(){
65 | _interface->bufferingEvent();
66 | }
67 |
68 | void EventsEmitter::TimeChanged(){
69 | _interface->timeChangeEvent();
70 | }
71 |
72 |
73 | void EventsEmitter::Playing(){
74 | _interface->playingEvent();
75 | }
76 |
77 |
78 | void EventsEmitter::Opening(){
79 | _interface->openEvent();
80 | }
81 |
82 |
83 | void EventsEmitter::Stopped(){
84 | qDebug() << "Stopped event \n";
85 | }
86 |
87 | void callbackEvents(const libvlc_event_t *e, void *data){
88 | MediaPlayer *core = (MediaPlayer *)data;
89 | switch(e->type)
90 | {
91 | case libvlc_MediaPlayerMediaChanged:
92 | qDebug() << "emit action \n";
93 | break;
94 | case libvlc_MediaParsedChanged:
95 | qDebug() << "libvlc_MediaParsedChanged action \n";
96 | break;
97 | case libvlc_MediaPlayerOpening:
98 | e_emitter->Opening();
99 | break;
100 | case libvlc_MediaPlayerBuffering:
101 | e_emitter->Buffering();
102 | break;
103 | case libvlc_MediaPlayerPlaying:
104 | e_emitter->Playing();
105 | break;
106 | case libvlc_MediaPlayerPaused:
107 | qDebug() << "MediaPlayerPaused \n";
108 | break;
109 | case libvlc_MediaPlayerStopped:
110 | e_emitter->Stopped();
111 | break;
112 | case libvlc_MediaPlayerForward:
113 | qDebug() << "MediaPlayerForward \n";
114 | break;
115 | case libvlc_MediaPlayerBackward:
116 | qDebug() << "MediaPlayerBackward \n";
117 | break;
118 | case libvlc_MediaPlayerEndReached:
119 | qDebug() << "MediaPlayerEndReached \n";
120 | break;
121 | case libvlc_MediaPlayerEncounteredError:
122 | qDebug() << "MediaPlayerEncounteredError \n";
123 | break;
124 | case libvlc_MediaPlayerTimeChanged:
125 | e_emitter->TimeChanged();
126 | break;
127 | case libvlc_MediaPlayerPositionChanged:
128 | e_emitter->PositionChanged();
129 | break;
130 | case libvlc_MediaPlayerSeekableChanged:
131 | qDebug() << "MediaPlayerSeekableChanged \n";
132 | break;
133 | case libvlc_MediaPlayerPausableChanged:
134 | qDebug() << "MediaPlayerPausableChanged \n";
135 | break;
136 | case libvlc_MediaPlayerTitleChanged:
137 | qDebug() << "MediaPlayerTitleChanged \n";
138 | break;
139 | case libvlc_MediaPlayerSnapshotTaken:
140 | qDebug() << "emit action \n";
141 | break;
142 | case libvlc_MediaPlayerLengthChanged:
143 | qDebug() << "MediaPlayerLengthChanged \n";
144 | break;
145 | case libvlc_MediaPlayerVout:
146 | e_emitter->Vout();
147 | break;
148 | default:
149 | break;
150 | }
151 | }
152 |
--------------------------------------------------------------------------------
/core/EventsEmitter.h:
--------------------------------------------------------------------------------
1 | #ifndef EVENTSEMITTER_H
2 | #define EVENTSEMITTER_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 |
10 | struct libvlc_event_t;
11 | class Interface;
12 |
13 | class EventsEmitter : public QObject {
14 | Q_OBJECT
15 |
16 | private:
17 | Interface * _interface;
18 |
19 | public:
20 | explicit EventsEmitter(QObject *parent = 0);
21 | EventsEmitter(Interface *);
22 |
23 | // void callbackEvents(const libvlc_event_t *, void *);
24 | libvlc_event_manager_t * events;
25 | void bindEvents();
26 | void unbindEvents();
27 | void Playing();
28 | void PositionChanged();
29 | void TimeChanged();
30 | void Paused();
31 | void Stopped();
32 | void Opening();
33 | void Buffering();
34 | void Vout();
35 |
36 | signals:
37 | public slots:
38 | };
39 |
40 | #endif // EVENTSEMITTER_H
41 |
--------------------------------------------------------------------------------
/core/Filters.cpp:
--------------------------------------------------------------------------------
1 | #include "Filters.h"
2 | #include
3 | #include
4 | #include
5 |
6 |
7 | Filters::Filters() {
8 | _filters_collection[QString("no-filter")] = 0;
9 | //_filters_collection[QString("anaglyph-filter")]=14;
10 |
11 | _filters_args[0]="vmem";
12 | _filters_args[1]="-q";
13 | _filters_args[2]="--quiet";
14 | _filters_args[3]="--ignore-config";
15 | _filters_args[4]="--vout";
16 | _filters_args[5]="--no-xlib";
17 | _filters_args[6]="-I";
18 | _filters_args[7]="dumy";
19 | _filters_args[8]="--no-video-title-show";
20 | _filters_args[9]="-v";
21 | _filters_args[10]="--intf=dummy";
22 | _filters_args[11]="--no-osd";
23 | _filters_args[12]="--no-loop";
24 | _filters_args[13]="--drop-late-frames";
25 | _filters_args[14]="--video-filter=Anaglyph";
26 | }
27 |
28 |
29 | void Filters::setFilter(int id) {
30 | _filters.clear();
31 |
32 | if(std::find(_activeFilters.begin(), _activeFilters.end(), id) == _activeFilters.end()){
33 | _activeFilters.insert(_activeFilters.end(), id);
34 | }
35 |
36 | for(unsigned it=0; it!=_activeFilters.size(); it++){
37 | _filters.insert(_filters.end(), _filters_args[_activeFilters[it]]);
38 | }
39 |
40 | //STUB
41 | std::cout << "Current filters list ";
42 | for(int i=0;i!=_filters.size();i++){
43 | std::cout << _filters[i] << " ";
44 | }
45 | std::cout << "\n";
46 | }
47 |
48 |
49 | void Filters::updateListFilters() {
50 | setFilter(0);
51 | }
52 |
53 |
54 | bool Filters::checkEnable(int id) {
55 | if(std::find(_activeFilters.begin(), _activeFilters.end(), id) == _activeFilters.end()){
56 | return false;
57 | } else return true;
58 | }
59 |
60 |
61 | void Filters::toogleFilter(int id) {
62 | if(std::find(_activeFilters.begin(), _activeFilters.end(), id) == _activeFilters.end()){
63 | setFilter(id);
64 | } else removeFilter(id);
65 | }
66 |
67 |
68 | void Filters::removeFilter(int id ) {
69 | if(std::find(_activeFilters.begin(), _activeFilters.end(), id) != _activeFilters.end()){
70 | _activeFilters.erase(_activeFilters.begin()+1);
71 | updateListFilters();
72 | }
73 | }
74 |
75 |
76 | std::vector & Filters::getArgv() {
77 | return _filters;
78 | }
79 |
--------------------------------------------------------------------------------
/core/Filters.h:
--------------------------------------------------------------------------------
1 | #ifndef FILTERS_H
2 | #define FILTERS_H
3 |
4 | #endif // FILTERS
5 | #include
6 | #include
7 |
8 |
9 | class Filters {
10 | public:
11 | static const int
12 | P_VMEM =0,
13 | P_Q =1,
14 | P_QUIET =2,
15 | P_IGNORE_CONFIG=3,
16 | P_VOUT =4,
17 | P_XLIB =5,
18 | P_I =6,
19 | P_DUMY =7,
20 | P_NO_VIDEO_TITLE_SHOW=8,
21 | P_V =9,
22 | P_INTF_DUMMY=10,
23 | P_NO_OSD=11,
24 | P_NO_LOOP=12,
25 | P_DROP_LATE_FRAME=13,
26 | P_ANAGLYPH_FILTER=14;
27 |
28 | std::vector & getArgv();
29 |
30 |
31 | Filters();
32 | void setFilter(int);
33 | void removeFilter(int);
34 | void updateListFilters();
35 | bool checkEnable(int);
36 | void toogleFilter(int);
37 |
38 |
39 | private:
40 | std::vector _filters;
41 | QMap _filters_collection;
42 | QMap _filters_args;
43 | std::vector _activeFilters;
44 | };
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/core/Instance.cpp:
--------------------------------------------------------------------------------
1 | #include "Instance.h"
2 | #include
3 | #include
4 | #include
5 | #include "Filters.h"
6 | #include
7 | #include
8 |
9 |
10 | Instance::Instance(std::vector & filters){
11 | const char * argv[filters.size()];
12 | for(int i=0;i<=filters.size();i++){
13 | argv[i]=filters[i];
14 | }
15 | _instance=libvlc_new(filters.size(), argv);
16 | }
17 |
18 |
19 | libvlc_instance_t * Instance::getInstance(){
20 | return _instance;
21 | }
22 |
23 |
24 | Instance::~Instance(){
25 | delete _instance;
26 | }
27 |
28 |
29 | void Instance::showActiveModules(){
30 | libvlc_module_description_t *t =libvlc_video_filter_list_get(_instance);
31 | qDebug() << QString::fromStdString( (char *)t->psz_longname );
32 | qDebug() << QString::fromStdString( (char *)t->p_next->psz_longname );
33 |
34 | while(t){
35 | qDebug() << QString::fromStdString( (char *)t->psz_shortname );
36 | t=t->p_next;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/core/Instance.h:
--------------------------------------------------------------------------------
1 | #ifndef INSTANCE_H
2 | #define INSTANCE_H
3 | #include
4 | #include
5 |
6 |
7 | class Filters;
8 | struct libvlc_module_description_t;
9 | struct libvlc_instance_t;
10 |
11 | /*!
12 | * \brief The Instance class
13 | */
14 | class Instance: public QObject {
15 | Q_OBJECT
16 | public:
17 | Instance(std::vector &);
18 |
19 | ~Instance();
20 |
21 | libvlc_instance_t * getInstance();
22 | void showActiveModules();
23 |
24 | private:
25 | libvlc_instance_t * _instance;
26 | };
27 |
28 | #endif // INSTANCE_H
29 |
--------------------------------------------------------------------------------
/core/Interface.cpp:
--------------------------------------------------------------------------------
1 | #include "Interface.h"
2 | #include "Player.h"
3 | #include "Filters.h"
4 | #include "VideoShow.h"
5 | #include "EventsEmitter.h"
6 | #include "ViewThread.h"
7 |
8 | #include "widgets/VideoSlider.h"
9 | #include "widgets/VideoWindow.h"
10 | #include "widgets/ControlPanel.h"
11 | #include
12 |
13 | #include
14 | #include
15 | #include "QTime"
16 | #include "QDebug"
17 | #include "QTimer"
18 |
19 | #include "Video.h"
20 | #include "Audio.h"
21 | #include "Media.h"
22 | #include
23 | #include
24 |
25 | #include
26 | #include
27 | #include
28 |
29 | #include
30 |
31 | struct libvlc_event_t;
32 | struct libvlc_event_manager_t;
33 | struct libvlc_media_t;
34 | struct libvlc_media_player_t;
35 | struct libvlc_instance_t;
36 | struct libvlc_new;
37 |
38 |
39 | QTimer *timer;
40 | QMutex mutex;
41 |
42 | /*!
43 | * \brief Interface::Interface
44 | * \param mp
45 | */
46 | Interface::Interface(Player * mp){
47 | //_videoSlider = new VideoSlider(mp);
48 | _videoWindow = new VideoWindow(mp);
49 | _controlPanel = new ControlPanel(mp);
50 |
51 | // parent->setWindowState(Qt::WindowFullScreen);
52 |
53 | windowW=800;
54 | windowH=620;
55 |
56 | _winID = _videoWindow->videoWindow->winId();
57 |
58 | view = new VideoShow(mp);
59 |
60 | showMediaThread = new ViewThread(view);
61 | thread = new QThread();
62 | showMediaThread->moveToThread(thread);
63 | thread->start();
64 | showMediaThread->run();
65 | _is_pause_event = false;
66 | _time_stopped = 0;
67 |
68 |
69 |
70 | scaleX = (double)_videoWindow->videoWindow->width()/(double)windowW;
71 | scaleY = (double)_videoWindow->videoWindow->height()/(double)windowH;
72 |
73 |
74 | ptrP = mp;
75 | this->connect(_controlPanel->ratio, SIGNAL(clicked()), this, SLOT(changeRatio()));
76 | this->connect(_controlPanel->mute, SIGNAL(clicked()), this, SLOT(mute()));
77 | this->connect(_controlPanel->open, SIGNAL(pressed()), this, SLOT(openLocal()));
78 | this->connect(_controlPanel->play, SIGNAL(pressed()), this, SLOT(play()));
79 | this->connect(_controlPanel->full, SIGNAL(pressed()), this, SLOT(fullscreen()));
80 | this->connect(_controlPanel->pause, SIGNAL(clicked()), this, SLOT(pause()));
81 | this->connect(_controlPanel->anaglyph, SIGNAL(clicked()), showMediaThread, SLOT(activeAnaglyph()));
82 |
83 |
84 |
85 | this->connect(_controlPanel->volumeLevelSlider, SIGNAL(sliderMoved(int)), this, SLOT(valueChange(int)));
86 | this->connect(_controlPanel->volumeLevelSlider, SIGNAL(valueChanged(int)), this, SLOT(valueChange(int)));
87 | this->connect(_controlPanel->progressSlider, SIGNAL(sliderReleased()), this, SLOT(trackSlider()));
88 | this->connect(_controlPanel->anaglyph, SIGNAL(pressed()), this, SLOT(enabled3d()));
89 | this->connect(mp, SIGNAL(emitResizeEvent(QResizeEvent *)), this, SLOT(resizeEvent(QResizeEvent *)));
90 | }
91 |
92 |
93 | void Interface::changeRatio(){
94 | view->changeRatio();
95 | }
96 |
97 |
98 | /*!
99 | * \brief Interface::mute
100 | */
101 | void Interface::mute(){
102 | ptrP->mediaPlayer->mute();
103 | }
104 |
105 |
106 | void Interface::triggerSliderMove(){
107 | qDebug() << "slide \n";
108 | }
109 |
110 |
111 | void Interface::openEvent(){
112 | qDebug() << "open event \n";
113 | }
114 |
115 | void Interface::fullscreen(){
116 | ptrP->setWindowState(Qt::WindowFullScreen);
117 | //ptrP->setWindowState( Qt::WindowNoState);
118 | }
119 |
120 |
121 | void Interface::play(){
122 | if(_is_pause_event){
123 | // Here you can update params render video.
124 | //ptrP->instance = new Instance(ptrP->filters->getArgv());
125 | ptrP->mediaPlayer = new MediaPlayer(ptrP->instance);
126 | ptrP->mediaPlayer->setPosition(_time_stopped);
127 | ptrP->media = new Media(ptrP->instance, _source_path);
128 | ptrP->mediaPlayer = new MediaPlayer(ptrP->instance);
129 | ptrP->mediaPlayer->open(ptrP->media, _videoWindow->videoWindow->winId(), _source_path, view, false);
130 |
131 |
132 | // Bind new play event
133 | this->connect(_controlPanel->play, SIGNAL(released()), ptrP->mediaPlayer, SLOT(play()));
134 |
135 | libvlc_media_player_navigate(ptrP->mediaPlayer->_mp, _time_stopped);
136 | libvlc_media_player_set_position(ptrP->mediaPlayer->_mp, _time_stopped);
137 | libvlc_media_player_set_time(ptrP->mediaPlayer->_mp, _time_stopped);
138 | }
139 | }
140 |
141 | void Interface::playEvent(){
142 | qDebug() << "play event \n";
143 | }
144 |
145 |
146 | void Interface::playingEvent(){
147 | qDebug() << "playing event \n";
148 | }
149 |
150 |
151 | void Interface::stopEvent(){
152 | qDebug() << "stop event \n";
153 | }
154 |
155 |
156 | void Interface::bufferingEvent(){
157 | qDebug() <<"buffering event \n";
158 | }
159 |
160 |
161 | void Interface::outFinishedEvent(){
162 | qDebug() << "outFinished event \n";
163 | }
164 |
165 |
166 | void Interface::timeChangeEvent(){
167 | getLastTime();
168 | }
169 |
170 | void Interface::updateStatusControlPanel(){
171 | timer = new QTimer(this);
172 | std::cout << "EMIT success!" << std::endl;
173 |
174 | int length_track = ptrP->mediaPlayer->length();
175 | int current_progress = ptrP->mediaPlayer->getTime();
176 |
177 | int h = ((length_track/1000)/60)/60;
178 | int m = (length_track/1000)/60;
179 | int s = length_track/1000;
180 | int d = 0;
181 | if(s>60){
182 | d=m*60;
183 | s-=d;
184 | }
185 |
186 | QString str;
187 | str.append(QString::number(m));
188 | str+=':';
189 | if(s<10){
190 | str+='0';
191 | }
192 | str.append(QString::number(s));
193 |
194 |
195 | _controlPanel->progressSlider->setMaximum(length_track);
196 | _controlPanel->progressSlider->setRange(0, length_track);
197 | _controlPanel->startTime->setText(str);
198 | }
199 |
200 |
201 | /*!
202 | * \brief Interface::openLocal
203 | */
204 | void Interface::openLocal(){
205 |
206 | const QString tr="Open file";
207 | QString file =
208 | QFileDialog::getOpenFileName(ptrP->widget, tr , QDir::homePath(), QString("Multimedia files(*)"));
209 |
210 | if (file.isEmpty())
211 | return;
212 |
213 | ptrP->mediaPlayer->release();
214 | ptrP->mediaPlayer = new MediaPlayer(ptrP->instance);
215 | ptrP->media = new Media(ptrP->instance, file);
216 | ptrP->mediaPlayer->open(ptrP->media, _winID, file, view, true);
217 | ptrP->eventManager = new EventsEmitter(this);
218 | _is_pause_event = false;
219 | }
220 |
221 |
222 | void Interface::getLastTime(){
223 | int length_track = ptrP->mediaPlayer->length();
224 |
225 | std::cout << length_track << std::endl;
226 | _controlPanel->progressSlider->setRange(0, length_track);
227 |
228 | int current_progress = ptrP->mediaPlayer->getTime();
229 |
230 | if(!_controlPanel->volumeLevelSlider->hasTracking()){
231 | _controlPanel->progressSlider->setValue(current_progress);
232 | }
233 |
234 | int h = ((current_progress/1000)/60)/60;
235 | int m = (current_progress/1000)/60;
236 | int s = current_progress/1000;
237 | int d = 0;
238 | if(s>60){
239 | d=m*60;
240 | s-=d;
241 | }
242 |
243 | QString str;
244 | str.append(QString::number(m));
245 | str+=':';
246 | if(s<10){
247 | str+='0';
248 | }
249 | str.append(QString::number(s));
250 | _controlPanel->startTime->setText(str);
251 | }
252 |
253 |
254 | void Interface::resizeEvent(QResizeEvent * event){
255 | int vWidth = ptrP->width()*scaleX,
256 | vHeight = ptrP->height()*scaleY;
257 |
258 | view->setFixedWidth(vWidth);
259 | view->setFixedHeight(vHeight);
260 |
261 | int coef_up_w = ptrP->width()/600,
262 | coef_up_h = ptrP->height()/500;
263 |
264 | _controlPanel->widget->setGeometry(
265 | QRect(
266 | (ptrP->width() * 0.07 ) * coef_up_w,
267 | (ptrP->height() * 0.8 ) * coef_up_h,
268 | ptrP->width() * 0.9,
269 | 100
270 | )
271 | );
272 |
273 | }
274 |
275 |
276 | /*!
277 | * \brief Interface::valueChange
278 | */
279 | void Interface::valueChange(int currentVolume){
280 | ptrP->mediaPlayer->voice(currentVolume);
281 | }
282 |
283 | /*!
284 | * \brief Interface::trackSlider
285 | */
286 | void Interface::trackSlider()
287 | {
288 | float value = _controlPanel->progressSlider->value();
289 | ptrP->mediaPlayer->setPosition(value);
290 | }
291 |
292 |
293 | void Interface::eventsEmitter(QString event = "default"){
294 | }
295 |
296 | // Pause and flush data from memory
297 | void Interface::pause(){
298 | // Get current time
299 | _time_stopped = ptrP->mediaPlayer->getTime();
300 | // Add 100ms for remove time event. It's just simple hack =)
301 | _time_stopped += 100;
302 | // Get path to stopped movie
303 | _source_path = ptrP->media->_locationSource;
304 | // Disconnect play event if media-player class and remove him
305 | this->disconnect(_controlPanel->play, SIGNAL(released()), ptrP->mediaPlayer, SLOT(play()));
306 | ptrP->mediaPlayer->release();
307 |
308 | _is_pause_event = true;
309 | }
310 |
311 |
--------------------------------------------------------------------------------
/core/Interface.h:
--------------------------------------------------------------------------------
1 | #ifndef INTERFACE_H
2 | #define INTERFACE_H
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | class Player;
9 | class VideoSlider;
10 | class VideoWindow;
11 | class ControlPanel;
12 | class EventsEmitter;
13 | class VideoShow;
14 | class ViewThread;
15 | class QString;
16 |
17 | struct libvlc_event_t;
18 | struct libvlc_event_manager_t;
19 | struct libvlc_media_t;
20 | struct libvlc_media_player_t;
21 |
22 | class Interface: public QObject {
23 | Q_OBJECT
24 | public:
25 | Interface(Player *);
26 | Player *ptrP;
27 | double scaleX;
28 | double scaleY;
29 | int windowW;
30 | int windowH;
31 |
32 | QThread *thread;
33 |
34 | VideoShow * view;
35 | ViewThread * showMediaThread;
36 |
37 | public slots:
38 | void openLocal();
39 | void mute();
40 | void valueChange(int);
41 | void trackSlider();
42 | void getLastTime();
43 | void eventsEmitter(QString);
44 | void updateStatusControlPanel();
45 | void resizeEvent(QResizeEvent *);
46 | void changeRatio();
47 |
48 | void play();
49 | void playEvent();
50 | void openEvent();
51 | void playingEvent();
52 | void stopEvent();
53 | void bufferingEvent();
54 | void outFinishedEvent();
55 | void timeChangeEvent();
56 | void pause();
57 | void triggerSliderMove();
58 |
59 | private slots:
60 | void fullscreen();
61 |
62 | private:
63 | EventsEmitter * eEmitter;
64 | int _winID;
65 | ControlPanel * _controlPanel;
66 | VideoSlider * _videoSlider;
67 | VideoWindow * _videoWindow;
68 | bool _is_pause_event;
69 | int _time_stopped;
70 | QString _source_path;
71 |
72 | };
73 |
74 | #endif // INTERFACE_H
75 |
--------------------------------------------------------------------------------
/core/Media.cpp:
--------------------------------------------------------------------------------
1 | #include "Media.h"
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | /*
9 | #include
10 | #include
11 | #include
12 | */
13 |
14 | #include "Instance.h"
15 |
16 |
17 | /*!
18 | * \brief Media::Media
19 | * \param location
20 | * \param locFileFlag
21 | * \param instance
22 | */
23 | Media::Media(Instance * instance, QString path){
24 | Init(instance, path) ;
25 | }
26 |
27 | /*!
28 | * \brief Media::Init
29 | * \param location
30 | * \param localFile
31 | * \param instance
32 | */
33 | void Media::Init(Instance *inst, QString & path){
34 | _instance = inst->getInstance();
35 | _locationSource = path;
36 | _media = libvlc_media_new_path(inst->getInstance(), path.toUtf8().data());
37 |
38 | }
39 |
40 | void Media::setMediaToPlaylist(QString path){
41 | /* path = QDir::toNativeSeparators(path);
42 | libvlc_media_t * ptr_media = libvlc_media_new_path(_instance, path.toUtf8().data());
43 | libvlc_media_add_media(_media_list, ptr_media);
44 | */
45 | }
46 |
47 |
48 | /*!
49 | * \brief Media::getMedia
50 | * \return
51 | */
52 | libvlc_media_t * Media::getMedia() const {
53 | return _media;
54 | }
55 |
56 | int Media::getMediaListCount() const {
57 | //return libvlc_media_count(_media_list);
58 | }
59 |
60 | /*!
61 | * \brief Media::getEventManager
62 | * \return
63 | */
64 | libvlc_event_manager_t * Media::getEventManager() const {
65 | return _events;
66 | }
67 |
68 | /*!
69 | * \brief Media::~Media
70 | */
71 | Media::~Media(){
72 | libvlc_media_release(_media);
73 | }
74 |
--------------------------------------------------------------------------------
/core/Media.h:
--------------------------------------------------------------------------------
1 | #ifndef MEDIA_H
2 | #define MEDIA_H
3 | #include
4 |
5 | struct libvlc_event_t;
6 | struct libvlc_event_manager_t;
7 | struct libvlc_media_t;
8 | struct libvlc_instance_t;
9 | struct libvlc_list_add_media;
10 |
11 |
12 | class Instance;
13 |
14 | /*!
15 | * \brief The Media class
16 | */
17 | class Media : public QObject {
18 | Q_OBJECT
19 | public:
20 | Media(Instance *, QString);
21 | ~Media();
22 |
23 | void Init(Instance *, QString &);
24 | libvlc_media_t * getMedia() const;
25 | libvlc_event_manager_t * getEventManager() const;
26 | int getMediaListCount() const;
27 | void setMediaToPlaylist(QString);
28 | QString _locationSource;
29 |
30 | signals:
31 | public slots:
32 |
33 | private:
34 | libvlc_media_t * _media;
35 | libvlc_event_manager_t *_events;
36 | libvlc_instance_t * _instance;
37 | };
38 |
39 | #endif // MEDIA_H
40 |
--------------------------------------------------------------------------------
/core/Mediaplayer.cpp:
--------------------------------------------------------------------------------
1 | #include "Mediaplayer.h"
2 | #include
3 | #include
4 | #include
5 | #include
6 |
7 | #include "Video.h"
8 | #include "Audio.h"
9 | #include "Media.h"
10 | #include "VideoShow.h"
11 | #include "Instance.h"
12 | #include "iostream"
13 | #include
14 | #include
15 | #include
16 | #include "stdio.h"
17 | #include
18 | #include
19 | #include
20 | #include
21 |
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 |
29 |
30 | struct libvlc_event_t;
31 | struct libvlc_event_manager_t;
32 | struct libvlc_media_t;
33 | struct libvlc_media_player_t;
34 | struct libvlc_instance_t;
35 | struct libvlc_new;
36 | struct libvlc_module_description_t; //* libvlc_video_filter_list_get
37 |
38 | const int WIDTH = 5000;
39 | const int HEIGHT = 5000;
40 | unsigned char * data_pixels = new unsigned char[ WIDTH * HEIGHT * 3];
41 |
42 | bool status=false;
43 |
44 |
45 | /*!
46 | * \brief MediaPlayer::MediaPlayer
47 | * \param instance
48 | * \param ui
49 | */
50 | MediaPlayer::MediaPlayer(Instance * instance){
51 | _mp = libvlc_media_player_new(instance->getInstance());
52 | _instance = instance;
53 | _mpEvents = libvlc_media_player_event_manager(_mp);
54 |
55 | _mpVideo = std::unique_ptr (new Video(_mp));
56 | _mpAudio = std::unique_ptr (new Audio(_mp));
57 |
58 | state=0;
59 | pix = data_pixels;
60 | }
61 |
62 |
63 | void MediaPlayer::release(){
64 | libvlc_media_player_stop(_mp);
65 | libvlc_media_player_release(_mp);
66 | }
67 |
68 |
69 | MediaPlayer::~MediaPlayer(){
70 | release();
71 | }
72 |
73 |
74 | /*!
75 | * \brief MediaPlayer::voice
76 | * \return
77 | */
78 | void MediaPlayer::voice(int val){
79 | _mpAudio->setVolume(val);
80 | }
81 |
82 |
83 | /*!
84 | * \brief MediaPlayer::mute
85 | * \return
86 | */
87 | void MediaPlayer::mute(){
88 | _mpAudio->toogleMute();
89 | }
90 |
91 | /*!
92 | * \brief MediaPlayer::setPosition
93 | * \param t
94 | */
95 | void MediaPlayer::setPosition(float t){
96 | libvlc_media_player_navigate(_mp, t);
97 | libvlc_media_player_set_position(_mp, t);
98 | libvlc_media_player_set_time(_mp, t);
99 | //libvlc_toggle_fullscreen(_mp);
100 | }
101 |
102 | /*!
103 | * \brief MediaPlayer::getCurentMedia
104 | * \return
105 | */
106 | Media * MediaPlayer::getCurentMedia() const{
107 | return _mpMedia;
108 | }
109 |
110 | /*!
111 | * \brief MediaPlayer::length
112 | * \return
113 | */
114 | int MediaPlayer::length() const {
115 | libvlc_time_t length = libvlc_media_player_get_length(_mp);
116 | return length;
117 | }
118 |
119 | /*!
120 | * \brief MediaPlayer::getTime
121 | * \return
122 | */
123 | int MediaPlayer::getTime() const {
124 | libvlc_time_t time = libvlc_media_player_get_time(_mp);
125 | return time;
126 | }
127 | /*!
128 | * \brief MediaPlayer::getInstance
129 | * \return
130 | */
131 | libvlc_media_player_t * MediaPlayer::getInstance(){
132 | return _mp;
133 | }
134 |
135 |
136 | unsigned char * MediaPlayer::getPixels(){
137 | return pix;
138 | }
139 |
140 |
141 | void print(std::string::size_type n, std::string const &s){
142 | if (n == std::string::npos) {
143 | std::cout << "not found\n";
144 | } else {
145 | std::cout << "found: " << s.substr(n) << '\n';
146 | }
147 | }
148 |
149 |
150 | std::string ssystem (const char *command){
151 | char tmpname [L_tmpnam];
152 | std::tmpnam ( tmpname );
153 | std::string scommand = command;
154 | std::string cmd = scommand + " >> " + tmpname;
155 | std::system(cmd.c_str());
156 | std::ifstream file(tmpname, std::ios::in );
157 | std::string result;
158 | if (file) {
159 | while (!file.eof()) result.push_back(file.get());
160 | file.close();
161 | }
162 | remove(tmpname);
163 | return result;
164 | }
165 |
166 |
167 | void * lock( void *data, void **p_pixels )
168 | {
169 | *p_pixels = data_pixels;
170 | return NULL;
171 | }
172 |
173 |
174 | void display( void *data, void *id )
175 | {
176 | (void) data;
177 | }
178 |
179 |
180 | void unlock( void *data, void *id, void *const *ipixels )
181 | {}
182 |
183 |
184 | /*
185 | int set_cb(void **data, char *format, unsigned *rate, unsigned *channels){
186 | //cx.mutex->lock();
187 | }
188 | */
189 |
190 | void task1(libvlc_media_player_t *_mp , libvlc_media_t * media, int w, int h){
191 | libvlc_media_player_set_media(_mp, media);
192 | //UYVY YUYV
193 | libvlc_video_set_format( _mp, "YUYV", w, h, w/2 * 4);
194 | libvlc_video_set_callbacks(_mp, lock, unlock, NULL, NULL);
195 |
196 | libvlc_audio_set_format(_mp, "S16N", NULL, NULL);
197 | //libvlc_audio_set_format_callbacks( _mp, (libvlc_audio_setup_cb)set_cb, NULL);
198 |
199 | libvlc_media_player_play(_mp);
200 | }
201 |
202 |
203 | /*!
204 | * \brief MediaPlayer::open
205 | * \param media
206 | * \param instance
207 | * \param wID
208 | */
209 | void MediaPlayer::open(Media * media, int wID, QString & path, VideoShow * vshow, bool state){
210 | _wID = wID;
211 | _mpMedia = media;
212 | pathToResource = path;
213 |
214 | width_view = 800;
215 | height_view = 370;
216 |
217 | char tmpname[400];
218 | //regexp for resolution
219 | QRegExp rx("(\\d{2,4})");
220 | //to capture the full path
221 | QRegExp getDir("(.*\..*/\).*\..*$");
222 | int pos_n=0, pos = 0;
223 |
224 | QStringList size_list, file_path;
225 | QString clone_path = path;
226 | QString current_path, string_search;
227 |
228 | file_path= path.split("/", QString::KeepEmptyParts);
229 | QString file = file_path.last();
230 |
231 | //get full path
232 | while ((pos_n = getDir.indexIn(clone_path , pos_n)) != -1) {
233 | current_path = getDir.cap(1);
234 | pos_n += getDir.matchedLength();
235 | }
236 |
237 | std::string line;
238 | std::string go_to = "cd ";
239 | //addition full path string in bash command
240 | go_to += "\""+current_path.toLocal8Bit().toStdString()+"\"";
241 |
242 | std::string bash = " && ffprobe -of flat=s=_ -show_entries stream=height,width ";
243 | bash = go_to + bash;
244 |
245 | bash += "\""+ file.toLocal8Bit().toStdString() +"\"";
246 | std::string respone_console = ssystem(bash.c_str());
247 | std::istringstream iss(respone_console);
248 |
249 | //get request result
250 | while ( std::getline(iss, line) ) {
251 | for(int i=0;igetMedia(), width_view, height_view);
267 | /*std::thread t1(task1, _mp,media->getMedia(), width_view, height_view);
268 | t1.join();
269 | */
270 |
271 | task1(_mp, media->getMedia(), width_view, height_view);
272 | vshow->run(width_view, height_view);
273 |
274 | qDebug() << width_view << "-- : " << height_view;
275 | state=1;
276 | }
277 |
278 |
279 | int MediaPlayer::getHeight(){
280 | return height_view;
281 | }
282 |
283 | int MediaPlayer::getWidth(){
284 | return width_view;
285 | }
286 |
287 | /*!
288 | * \brief MediaPlayer::seek
289 | */
290 | void MediaPlayer::seek(){
291 | /*
292 | libvlc_media_release(_vlcMedia);
293 | libvlc_media_player_release(_vlcMediaPlayer);
294 | */
295 | // libvlc_media_player_set_position(_vlcMediaPlayer, 120.0);
296 | }
297 |
298 | /*!
299 | * \brief MediaPlayer::pause
300 | */
301 | void MediaPlayer::pause(){
302 |
303 | libvlc_media_player_pause(_mp);
304 | libvlc_media_player_set_pause(_mp, 1);
305 |
306 | }
307 |
308 | void MediaPlayer::error(){}
309 |
--------------------------------------------------------------------------------
/core/Mediaplayer.h:
--------------------------------------------------------------------------------
1 | #ifndef MEDIAPLAYER_H
2 | #define MEDIAPLAYER_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include "ui_player.h"
10 | #include "Player.h"
11 | #include
12 | #include
13 |
14 | class Instance;
15 | class Media;
16 | class Video;
17 | class Audio;
18 | class VideoShow;
19 |
20 | struct libvlc_event_t;
21 | struct libvlc_event_manager_t;
22 | struct libvlc_media_t;
23 | struct libvlc_media_player_t;
24 | struct libvlc_media_list_player_t;
25 |
26 |
27 | /*!
28 | * \brief The MediaPlayer class
29 | */
30 | class MediaPlayer: public QObject {
31 | Q_OBJECT
32 | public:
33 | MediaPlayer(Instance *);
34 | ~MediaPlayer();
35 |
36 | static unsigned char * pixels;
37 |
38 | Media * getCurentMedia() const;
39 | libvlc_media_player_t * getInstance();
40 |
41 |
42 | int getTime() const;
43 | int length() const;
44 | void open(Media *, int, QString &, VideoShow *, bool);
45 | void setPosition(float);
46 | void error();
47 |
48 | libvlc_media_player_t * _mp;
49 | std::unique_ptr _mpVideo;
50 | std::unique_ptr _mpAudio;
51 | Media * _mpMedia;
52 | QString pathToResource;
53 | Instance * _instance;
54 |
55 | int getHeight();
56 | int getWidth();
57 |
58 | unsigned char * getPixels();
59 |
60 | int width_view,
61 | height_view;
62 | unsigned char * pix;
63 | int state;
64 |
65 |
66 | void voice(int);
67 | void mute();
68 |
69 | public slots:
70 | void pause();
71 | void seek();
72 | void release();
73 |
74 | private slots:
75 |
76 |
77 | private:
78 |
79 | libvlc_event_manager_t *_mpEvents;
80 | Ui::Player * _ui;
81 | int currentTime;
82 | int _wID;
83 | //WId _focusWID;
84 |
85 | };
86 |
87 | #endif // MEDIAPLAYER_H
88 |
--------------------------------------------------------------------------------
/core/Options.h:
--------------------------------------------------------------------------------
1 | #ifndef OPTIONS_H
2 | #define OPTIONS_H
3 |
4 |
5 | class Options {
6 | public:
7 | Options();
8 | };
9 |
10 |
11 | #endif
12 |
--------------------------------------------------------------------------------
/core/Player.cpp:
--------------------------------------------------------------------------------
1 |
2 | #include "iostream"
3 | #include "QtCore/QTime"
4 | #include "Filters.h"
5 | #include "Player.h"
6 | #include "ui_player.h"
7 | #include "vlc/libvlc.h"
8 | #include
9 |
10 | using namespace std;
11 |
12 |
13 | Player::Player(QWidget *parent) :
14 | QMainWindow(parent),
15 | ui(new Ui::Player){
16 | #ifdef Q_WS_X11
17 | if(QX11Info::isCompositingManagerRunning())
18 | setAttribute(Qt::WA_TranslucentBackground);
19 | #endif
20 | ui->setupUi(this);
21 | widget = parent;
22 |
23 | filters = new Filters();
24 | //
25 | //filters->setFilter(Filters::P_Q);
26 | //filters->setFilter(Filters::P_NO_VIDEO_TITLE_SHOW);
27 | //filters->setFilter(Filters::P_QUIET);
28 | //filters->setFilter(Filters::P_IGNORE_CONFIG);
29 | filters->setFilter(Filters::P_QUIET);
30 | //filters->setFilter(Filters::P_XLIB);
31 | //filters->setFilter(Filters::P_IGNORE_CONFIG);
32 | filters->setFilter(Filters::P_NO_LOOP);
33 | filters->setFilter(Filters::P_DROP_LATE_FRAME);
34 | filters->setFilter(Filters::P_NO_OSD);
35 | filters->setFilter(Filters::P_VOUT);
36 | filters->setFilter(Filters::P_VMEM);
37 |
38 | instance = new Instance(filters->getArgv());
39 |
40 | // Output all modules of current VLClib
41 | //instance->showActiveModules();
42 |
43 | mediaPlayer = new MediaPlayer(instance);
44 | interface = new Interface(this);
45 | }
46 |
47 |
48 | Player::~Player(){
49 | delete mediaPlayer;
50 | delete interface;
51 | delete video;
52 | delete ui;
53 | }
54 |
55 |
56 | void Player::updateInstance(){}
57 |
58 |
59 | void Player::resizeEvent(QResizeEvent * resizeEvent){
60 | emit emitResizeEvent(resizeEvent);
61 | }
62 |
63 |
--------------------------------------------------------------------------------
/core/Player.h:
--------------------------------------------------------------------------------
1 | #ifndef PLAYER_H
2 | #define PLAYER_H
3 |
4 | #include
5 | #include
6 |
7 | #include "Instance.h"
8 | #include "Interface.h"
9 | #include "Mediaplayer.h"
10 | #include "Media.h"
11 | #include "Video.h"
12 | #include "Audio.h"
13 |
14 | struct libvlc_event_t;
15 | struct libvlc_event_manager_t;
16 | struct libvlc_media_t;
17 | struct libvlc_media_player_t;
18 | struct libvlc_instance_t;
19 | struct libvlc_new;
20 | struct libvlc_event_manager_t;
21 |
22 | class Filters;
23 | class Interface;
24 | class Video;
25 | class Audio;
26 | class MediaPlayer;
27 | class Media;
28 | class EventsEmitter;
29 |
30 | namespace Ui {
31 | class Player;
32 | }
33 |
34 |
35 | class Player : public QMainWindow {
36 | Q_OBJECT
37 |
38 | public:
39 | Ui::Player *ui;
40 | explicit Player(QWidget *parent = 0);
41 | ~Player();
42 |
43 | QWidget * widget;
44 | Filters * filters;
45 | Instance * instance;
46 | Interface * interface;
47 | Video * video;
48 | Audio * audio;
49 | Media * media;
50 | EventsEmitter * eventManager;
51 | MediaPlayer * mediaPlayer;
52 |
53 | void updateInstance();
54 | void resizeEvent(QResizeEvent *);
55 | int wId;
56 |
57 | signals:
58 | void emitResizeEvent(QResizeEvent *);
59 |
60 | private slots:
61 |
62 |
63 | private:
64 |
65 | };
66 |
67 | #endif // PLAYER_H
68 |
--------------------------------------------------------------------------------
/core/Shaders.h:
--------------------------------------------------------------------------------
1 | const char * FProgram = "\
2 | varying vec4 pos;\
3 | varying vec2 vTexCoord;\
4 | varying float tex;\
5 | varying float pos_m;\
6 | uniform float is_anaglyph;\
7 | uniform sampler2D y_tex;\
8 | void main( void )\
9 | { \
10 | \
11 | vec4 Y;\
12 | \
13 | if(is_anaglyph == 1.0){\
14 | if(tex==1.0){\
15 | Y = texture2D(y_tex, vTexCoord).rgba;\
16 | } else {\
17 | Y = texture2D(y_tex, vTexCoord * vec2(1.0, 1.0)).rgba;\
18 | }\
19 | } else {\
20 | Y = texture2D(y_tex, vTexCoord + vec2(0.0, 0.0)).rgba;\
21 | }\
22 | \
23 | vec4 color_r, v_color;\
24 | \
25 | float y=1.1643*(Y.r-0.0625);\
26 | float u=Y.g-0.5;\
27 | float v=Y.a-0.5;\
28 | float r=y+1.5958*v;\
29 | float g=y-0.39173*u-0.81290*v;\
30 | float b=y+2.017*u;\
31 | \
32 | if(is_anaglyph == 0.0){\
33 | v_color = vec4(r, g, b, 1.0);\
34 | } else {\
35 | color_r = texture2D(y_tex, vTexCoord + vec2(0.16, 0.0)).rgba;\
36 | v_color = vec4(1.0, g, b, 1.0) * vec4(color_r.r, 1.0, 1.0, 1.0);\
37 | }\
38 | gl_FragColor = v_color;\
39 | }";
40 |
41 |
42 | const char* YUV420P_VS ="\
43 | varying vec4 pos;\
44 | varying vec4 color;\
45 | uniform float scale;\
46 | attribute vec2 position;\
47 | uniform vec2 size_frame;\
48 | varying float tex;\
49 | varying float pos_m;\
50 | varying vec2 vTexCoord;\
51 | void main(){\
52 | tex = scale;\
53 | vTexCoord = position.xy * vec2(1.0, 1.0) + vec2(0.0, 0.0);\
54 | float angle = 3.14/180.0 * 180.0;\
55 | \
56 | \
57 | mat4 translate = mat4(\
58 | vec4( 1.0, 0.0, 0.0, -0.5),\
59 | vec4(0.0, 1.0, 0.0, -0.5),\
60 | vec4(0.0, 0.0, 1.0, 0.0),\
61 | vec4(0.0, 0.0, 0.0, 1.0)\
62 | );\
63 | \
64 | \
65 | \
66 | vec4 vec_rotate = vec4(position.xy, 0.0, 1.0);\
67 | vec_rotate = vec_rotate * translate;\
68 | vec3 rot = vec_rotate.xyz;\
69 | gl_Position = vec4(rot.x * size_frame.x, -rot.y * size_frame.y, 0.0, 1.0);\
70 | }";
71 |
--------------------------------------------------------------------------------
/core/Video.cpp:
--------------------------------------------------------------------------------
1 | #include "Video.h"
2 | #include
3 | #include
4 | #include
5 |
6 |
7 | Video::Video(QObject *parent) : QObject(parent)
8 | {}
9 |
10 | Video::Video(libvlc_media_player_t * player){
11 | mp=player;
12 | }
13 |
14 | bool Video::getSnapshot(const QString & path){
15 | bool status = 0;
16 | if (mp && libvlc_media_player_has_vout(mp)) {
17 | status = libvlc_video_take_snapshot(mp, 0, path.toUtf8().data(), 0, 0) + 1;
18 | }
19 | return status;
20 | }
21 |
22 |
23 | void Video::showLogo(const QString & path, int x, int y, int opacity){
24 | if(mp && libvlc_media_player_has_vout(mp)){
25 | libvlc_video_set_logo_string((mp), libvlc_logo_file, path.toUtf8().data());
26 | libvlc_video_set_logo_int((mp), libvlc_logo_x, x);
27 | libvlc_video_set_logo_int((mp), libvlc_logo_y, y);
28 | libvlc_video_set_logo_int((mp), libvlc_logo_opacity, opacity);
29 | libvlc_video_set_logo_int((mp), libvlc_logo_enable, 1);
30 | }
31 | }
32 |
33 |
34 | void Video::setRatio(QString & param){
35 | if (mp && libvlc_media_player_has_vout(mp)) {
36 | libvlc_video_set_aspect_ratio(mp, param.toUtf8().data());
37 | }
38 | }
39 |
40 |
41 | void Video::setPause(){
42 | libvlc_media_player_pause(mp);
43 | libvlc_media_player_set_pause(mp, 1);
44 | }
45 |
46 | int Video::getTrackCount() const{
47 | int count = -1;
48 | if (mp){
49 | count = libvlc_video_get_track_count(mp);
50 | }
51 | return count;
52 | }
53 |
54 |
55 | // Get list of id's
56 | std::vector Video::getTrackId() const{
57 | std::vector list_id;
58 |
59 | if (mp) {
60 | libvlc_track_description_t *desc;
61 | int track_count = getTrackCount();
62 |
63 | desc = libvlc_video_get_track_description(mp);
64 | list_id.push_back(desc->i_id);
65 |
66 | if (track_count > 1) {
67 | for(int i = 1; i < track_count; i++) {
68 | desc = desc->p_next;
69 | list_id.push_back(desc->i_id);
70 | }
71 | }
72 | }
73 | return list_id;
74 | }
75 |
--------------------------------------------------------------------------------
/core/Video.h:
--------------------------------------------------------------------------------
1 | #ifndef VIDEO_H
2 | #define VIDEO_H
3 | #include
4 |
5 | struct libvlc_media_list_player_t;
6 | struct libvlc_media_player_has_vout;
7 | struct libvlc_media_player_t;
8 | struct libvlc_media_list_t;
9 |
10 |
11 | /*!
12 | * \brief The Video class
13 | */
14 | class Video : public QObject {
15 | Q_OBJECT
16 | public:
17 | explicit Video(QObject *parent = 0);
18 | Video(libvlc_media_player_t *);
19 |
20 | void showLogo(const QString &, int, int, int);
21 | bool getSnapshot(const QString &);
22 | void setRatio(QString &);
23 |
24 | std::vector getTrackId() const;
25 | int getTrackCount() const;
26 |
27 | signals:
28 |
29 | public slots:
30 | void setPause();
31 |
32 | private:
33 | libvlc_media_player_t * mp;
34 |
35 | };
36 |
37 | #endif // VIDEO_H
38 |
--------------------------------------------------------------------------------
/core/VideoShow.cpp:
--------------------------------------------------------------------------------
1 | #include "VideoShow.h"
2 | #include "Player.h"
3 | #include "Shaders.h"
4 | #include "Anaglyph.h"
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include
15 | #include
16 | #include
17 |
18 |
19 | #define OFFSET_BUFFER(bytes) ((GLfloat *)NULL + bytes)
20 | float scaleX = 1.0f, scaleY = 1.0f,
21 | coefX = 1.0, coefY = 1.0;
22 |
23 |
24 | GLuint Program;
25 | // ID attribute
26 | GLint Attrib_vertex;
27 | // ID uniform val of color
28 | GLint Unif_color;
29 | // ID Vertex buffer object
30 | GLuint VBO, VBO_2, VBOt;
31 |
32 | // ! Вершина
33 | struct vertex
34 | {
35 | GLfloat x;
36 | GLfloat y;
37 | };
38 |
39 |
40 | float mVerticesData[] = { -1.f, 1.f, 0.0f, // Position 0
41 | 0.0f, 0.0f, // TexCoord 0
42 | -1.f, -1.f, 0.0f, // Position 1
43 | 0.0f, 1.0f, // TexCoord 1
44 | 1.f, -1.f, 0.0f, // Position 2
45 | 1.0f, 1.0f, // TexCoord 2
46 | 1.f, 1.f, 0.0f, // Position 3
47 | 1.0f, 0.0f // TexCoord 3
48 | };
49 |
50 | // Init VBO for 2.x textures
51 | void VideoShow::initVBO(){
52 | glGenBuffers(1, &VBO);
53 | glBindBuffer(GL_ARRAY_BUFFER, VBO);
54 | glBufferData(GL_ARRAY_BUFFER, sizeof(__vertex), __vertex, GL_DYNAMIC_DRAW);
55 |
56 | glGenBuffers(1, &VBO_2);
57 | glBindBuffer(GL_ARRAY_BUFFER, VBO_2);
58 | glBufferData(GL_ARRAY_BUFFER, sizeof(__vertex_2), __vertex_2, GL_DYNAMIC_DRAW);
59 |
60 |
61 | glGenBuffers(1, &VBOt);
62 | glBindBuffer(GL_TEXTURE_BUFFER, VBOt);
63 | glBufferData(GL_TEXTURE_BUFFER, sizeof(_textureCords), _textureCords, GL_DYNAMIC_DRAW);
64 | }
65 |
66 | void VideoShow::modeAnaglyph(){
67 | active_anaglyph = active_anaglyph == 1.0 ? 0.0:1.0;
68 | qDebug() << "anaglyph;";
69 | }
70 |
71 |
72 | VideoShow::VideoShow(QWidget *parent) : QGLWidget(parent)
73 | {
74 | std::cout << glGetString(GL_VERSION) << "test " << std::endl;
75 | active_anaglyph = 0.0;
76 |
77 | ptrPlayer = (Player*)parent;
78 | this->setGeometry(0, 0, 1200, 850);
79 | this->setBaseSize(QSize(1200, 850));
80 | this->setMouseTracking(true);
81 | this->setStyleSheet(QString("background-color: #000;width:100%;height:100%;"));
82 | this->setAutoFillBackground(true);
83 |
84 |
85 | _textureCords[0]=1.0f;
86 | _textureCords[1]=0.0f,
87 | _textureCords[2]=1.0f;
88 | _textureCords[3]=1.0f,
89 | _textureCords[4]=0.0f;
90 | _textureCords[5]=1.0f;
91 | _textureCords[6]=1.0f;
92 | _textureCords[7]=0.0f;
93 |
94 |
95 | __vertex[0] = 0.0;
96 | __vertex[1] = 1.0;
97 | __vertex[2] = 1.0;
98 | __vertex[3] = 1.0;
99 | __vertex[4] = 1.0;
100 | __vertex[5] = 0.0;
101 | __vertex[6] = 0.0;
102 | __vertex[7] = 0.0;
103 |
104 | _logoVertex[0][0] = 0.3f;
105 | _logoVertex[0][1] = 0.3f;
106 | _logoVertex[1][0] = 0.3f;
107 | _logoVertex[1][1] = -0.3f;
108 | _logoVertex[2][0] = -0.3f;
109 | _logoVertex[2][1] = -0.3f;
110 | _logoVertex[3][0] = -0.3f;
111 | _logoVertex[3][1] = 0.3f;
112 |
113 | _stereo = new Anaglyph(2000.0f,
114 | 0.025f,
115 | 1.1333f,
116 | 45.0f,
117 | 0.0f,
118 | 10000.0f
119 | );
120 |
121 | this->show();
122 | }
123 |
124 |
125 | void VideoShow::initShader()
126 | {
127 | GLuint vShader, fShader;
128 | // Init vertex and textures shaders
129 | vShader = glCreateShader(GL_VERTEX_SHADER);
130 | glShaderSource(vShader, 1, &YUV420P_VS, NULL);
131 | glCompileShader(vShader);
132 |
133 | fShader = glCreateShader(GL_FRAGMENT_SHADER);
134 | glShaderSource(fShader, 1, &FProgram, NULL);
135 | glCompileShader(fShader);
136 |
137 | prog = glCreateProgram();
138 | glAttachShader(prog, vShader);
139 | glAttachShader(prog, fShader);
140 |
141 | glLinkProgram(prog);
142 | glUseProgram(prog);
143 |
144 |
145 |
146 | glUniform1i(glGetUniformLocation(prog, "y_tex"), 0);
147 | glUniform1i(glGetUniformLocation(prog, "u_tex"), 1);
148 | glUniform1i(glGetUniformLocation(prog, "v_tex"), 2);
149 | glUniform1f(glGetUniformLocation(prog, "scale"), 5.0);
150 |
151 | const char* attr_name = "scale";
152 | Attrib_vertex = glGetUniformLocation(prog, attr_name);
153 |
154 | y_tex_s = glGetUniformLocation(prog, "y_tex");
155 | u_tex_s = glGetUniformLocation(prog, "u_tex");
156 | v_tex_s = glGetUniformLocation(prog, "v_tex");
157 |
158 | u_pos = glGetUniformLocation(prog, "position");
159 | pos_m = glGetUniformLocation(prog, "pos_m");
160 | tex_coord = glGetUniformLocation(prog, "tex");
161 | anaglyph = glGetUniformLocation(prog, "is_anaglyph");
162 | size_frame = glGetUniformLocation(prog, "size_frame");
163 | }
164 |
165 |
166 | void VideoShow::setupTextures() {
167 | glUseProgram(prog);
168 | glGenTextures(1, &y_tex);
169 | glBindTexture(GL_TEXTURE_2D, y_tex);
170 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA , _frame_width/2, _frame_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
171 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
172 | //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
173 |
174 | //glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
175 | //glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
176 |
177 |
178 | glGenTextures(1, &u_tex);
179 | glBindTexture(GL_TEXTURE_2D, u_tex);
180 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _frame_width/2, _frame_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
181 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
182 | //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
183 |
184 | //glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
185 | //glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
186 | }
187 |
188 |
189 | GLuint glTexture, y_tex, u_tex, v_tex;
190 | void VideoShow::initializeGL(){
191 | initializeGLFunctions();
192 | //QOpenGLFunctions();
193 | //initializeOpenGLFunctions();
194 | //initializeOpenGLFunctions();
195 | glClearColor (0.0, 0.0, 0.0, 0.0);
196 | glEnable( GL_TEXTURE_2D );
197 | logoInit();
198 |
199 | }
200 |
201 |
202 | void VideoShow::run(int frame_width, int frame_height){
203 | _data_frame = ptrPlayer->mediaPlayer->getPixels();
204 |
205 | _ratio_x = 1.0f;
206 | _ratio_y = 1.0f;
207 |
208 | _frame_width = frame_width;
209 | _frame_height= frame_height;
210 |
211 | _texture_height = frame_height;
212 | _texture_width = frame_width;
213 |
214 |
215 | initVBO();
216 | initShader();
217 | setupTextures();
218 | // glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA , _texture_width, _texture_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, _data_frame );
219 | // glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
220 |
221 | resizeGL(this->width(), this->height());
222 | //setup();
223 | ptrPlayer->mediaPlayer->state = 1;
224 | }
225 |
226 |
227 | void VideoShow::paintGL(){
228 | glUniform1f(anaglyph, active_anaglyph);
229 | if( ptrPlayer->mediaPlayer->state == 1){
230 | _stereo->ApplyLeftFrustum();
231 | videoRender();
232 |
233 | glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_TRUE);
234 | glClear(GL_DEPTH_BUFFER_BIT) ;
235 |
236 | _stereo->ApplyRightFrustum();
237 | videoRender();
238 | glColorMask(GL_FALSE, GL_TRUE, GL_TRUE, GL_FALSE);
239 | } else {
240 | showLogo();
241 | }
242 | }
243 |
244 |
245 | int width_, height_;
246 |
247 | void VideoShow::videoRender()
248 | {
249 | glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
250 |
251 | glUseProgram(prog);
252 |
253 | glUniform1f(Attrib_vertex, 1);
254 |
255 | glActiveTexture(GL_TEXTURE0);
256 | glBindTexture(GL_TEXTURE_2D, y_tex);
257 | glUniform1i(y_tex_s, 0);
258 | glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, _frame_width/2, _frame_height, GL_RGBA, GL_UNSIGNED_BYTE, _data_frame);
259 |
260 |
261 | glBindBuffer(GL_ARRAY_BUFFER, VBO);
262 | glEnableVertexAttribArray(u_pos);
263 | glVertexPointer(2, GL_FLOAT, 0, 0);
264 |
265 | glEnableClientState(GL_VERTEX_ARRAY);
266 | glEnableClientState(GL_TEXTURE_COORD_ARRAY);
267 |
268 | glDrawArrays(GL_QUADS, 0, 4);
269 |
270 | glDisableClientState(GL_TEXTURE_COORD_ARRAY);
271 | glDisableClientState(GL_VERTEX_ARRAY);
272 |
273 |
274 | glEnableClientState(GL_TEXTURE_COORD_ARRAY);
275 | glEnableClientState(GL_VERTEX_ARRAY);
276 | glVertexPointer(2, GL_FLOAT, 0, _vertex);
277 | glTexCoordPointer(2, GL_FLOAT, 0, &_textureCords);
278 | glDisableClientState(GL_VERTEX_TEXTURE);
279 |
280 | glDisableClientState(GL_VERTEX_TEXTURE);
281 | glDisableClientState(GL_VERTEX_ARRAY);
282 | }
283 |
284 |
285 | void VideoShow::changeRatio(){
286 | /*
287 | if(_frame_height < _frame_width){
288 | _ratio_y = _frame_width/_frame_height;
289 | _ratio_x = 1.0;
290 | } else {
291 | _ratio_y = 1.0;
292 | _ratio_x = _frame_height/_frame_width;
293 | }
294 | */
295 |
296 |
297 | if(_frame_height<_frame_width){
298 | float _w = _frame_width;
299 | float _h = (_frame_width/16) * 9;
300 | _frame_width = _h * _frame_width/_frame_height;
301 | _ratio_y = _w/_h;
302 | } else {
303 | float _w = _frame_width;
304 | float _h = (_frame_width/16) * 9;
305 | _ratio_y = _h/_w;
306 | }
307 |
308 | resizeGL(this->width(), this->height());
309 | }
310 |
311 |
312 | void VideoShow::resizeGL(int width, int height){
313 | glMatrixMode(GL_PROJECTION);
314 | glLoadIdentity();
315 |
316 | float w = (float)width;
317 | float h = (float)height;
318 |
319 | float c_x = (float)w/(float)h;
320 | float c_y = (float)h/(float)w;
321 |
322 |
323 | _ratio_coeff_x=2.0 * _ratio_x,
324 | _ratio_coeff_y=2.0 * _ratio_y;
325 |
326 |
327 | if(w/h > (float)_frame_width/(float)_frame_height){
328 | _ratio_coeff_y = _ratio_coeff_y/h * h;
329 | _ratio_coeff_x = _ratio_coeff_x/w * (h * _frame_width/_frame_height);
330 |
331 | } else if(h/w >= c_y){
332 | _ratio_coeff_x = _ratio_coeff_x/w * w;
333 | _ratio_coeff_y = _ratio_coeff_y/h * (w * _frame_height/_frame_width);
334 | }
335 |
336 | qDebug() << _ratio_coeff_x << " " << _ratio_coeff_y;
337 |
338 |
339 | glUniform2f(size_frame, _ratio_coeff_x, _ratio_coeff_y);
340 |
341 | width_ = width;
342 | height_ = height;
343 |
344 | glViewport(0, 0, (GLint)width, (GLint)height);
345 | }
346 |
347 | // Keyboard control
348 | void VideoShow::keyPressEvent(QKeyEvent* pe)
349 | {
350 | switch (pe->key())
351 | {
352 | case Qt::Key_Z:
353 |
354 | changeRatio();
355 | break;
356 |
357 | case Qt::Key_X:
358 | break;
359 |
360 | case Qt::Key_Space:
361 | break;
362 |
363 | case Qt::Key_Escape:
364 | break;
365 |
366 | case Qt::Key_Plus:
367 | break;
368 |
369 | case Qt::Key_Equal:
370 | break;
371 |
372 | case Qt::Key_Minus:
373 | break;
374 |
375 | case Qt::Key_Up:
376 | break;
377 |
378 | case Qt::Key_Down:
379 | break;
380 |
381 | case Qt::Key_Left:
382 | break;
383 |
384 | case Qt::Key_Right:
385 | break;
386 |
387 | }
388 |
389 | //updateGL();
390 | }
391 |
392 |
393 | void VideoShow::logoInit(){
394 | QImage * img=new QImage(":img/logo.png");
395 | _img = img->convertToFormat(QImage::Format_RGBA8888);
396 |
397 | _logo_width = img->width();
398 | _logo_height= img->height();
399 |
400 | glEnable (GL_BLEND);
401 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
402 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA , _logo_width, _logo_height, 0, GL_RGBA , GL_UNSIGNED_INT_8_8_8_8_REV, _img.bits());
403 | glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
404 |
405 | }
406 |
407 |
408 | void VideoShow::showLogo(){
409 | glTexSubImage2D ( GL_TEXTURE_2D, 0, 0, 0, _logo_width, _logo_height, GL_BGRA, GL_UNSIGNED_BYTE, _img.bits());
410 | glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
411 |
412 | glVertexPointer(2, GL_FLOAT, 0, _logoVertex);
413 | glTexCoordPointer(2, GL_FLOAT, 0, &_textureCords);
414 | glEnableClientState(GL_TEXTURE_COORD_ARRAY);
415 | glEnableClientState(GL_VERTEX_ARRAY);
416 | glDrawArrays(GL_POLYGON, 0, 4);
417 | glDisableClientState(GL_VERTEX_TEXTURE);
418 | glDisableClientState(GL_VERTEX_ARRAY);
419 |
420 | }
421 |
--------------------------------------------------------------------------------
/core/VideoShow.h:
--------------------------------------------------------------------------------
1 | #ifndef VIDEOSHOW_H
2 | #define VIDEOSHOW_H
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include
13 |
14 |
15 | class Player;
16 | class StereoCamera;
17 | class Anaglyph;
18 |
19 |
20 | class VideoShow : public QGLWidget, protected QGLFunctions {
21 | Q_OBJECT
22 |
23 | protected:
24 | int _texture_width,
25 | _texture_height;
26 |
27 | Anaglyph * _stereo;
28 |
29 | void paintGL();
30 | void initializeGL();
31 | void resizeGL(int, int);
32 | void videoRender();
33 | void keyPressEvent(QKeyEvent *);
34 | void initShader();
35 | void initVBO();
36 | void freeShader();
37 | void freeVBO();
38 | void setupTextures();
39 | void setup();
40 |
41 | void setYPixels(uint8_t*, int);
42 | void setVPixels(uint8_t*, int);
43 | void setUPixels(uint8_t*, int);
44 |
45 |
46 | // Here you cant bind new keyboard events
47 | /*void mousePressEvent(QMouseEvent* pe);
48 | void mouseMoveEvent(QMouseEvent* pe);
49 | void mouseReleaseEvent(QMouseEvent* pe);
50 | void wheelEvent(QWheelEvent* pe);
51 | void keyPressEvent(QKeyEvent* pe);
52 | */
53 |
54 | private:
55 | enum mode{ SIMPLE, STEREO, ANAGLYPH };
56 | enum ratioMode{DEFAULT, STANDART};
57 | mode _current_mode, _current_ratio;
58 |
59 | GLuint vao;
60 | uint8_t* y_pixels;
61 | uint8_t* u_pixels;
62 | uint8_t* v_pixels;
63 |
64 |
65 |
66 | GLuint y_tex_s;
67 | GLuint u_tex_s;
68 | GLuint v_tex_s;
69 |
70 |
71 | GLuint y_tex;
72 | GLuint sampler_texture;
73 | GLuint u_tex;
74 | GLuint v_tex;
75 | GLuint vert;
76 | GLuint frag;
77 | GLuint prog;
78 | GLint u_pos, pos_m;
79 | GLint size_frame;
80 | GLint tex_coord;
81 | GLint anaglyph;
82 | float active_anaglyph;
83 |
84 | struct vertex
85 | {
86 | GLfloat x;
87 | GLfloat y;
88 | };
89 |
90 | GLfloat __vertex[8], __vertex_2[8];
91 |
92 | GLfloat _vertex[4][2], _logoVertex[4][2];
93 | float _textureCords[8];
94 | unsigned char * _data_frame;
95 | unsigned char data_logo[200*200*4];
96 |
97 | QImage _logo_texture, _img;
98 | QOpenGLTexture * texture;
99 |
100 | int _frame_width, _frame_height;
101 | int _logo_width, _logo_height;
102 | float _ratio_coeff_x, _ratio_coeff_y;
103 | float _ratio_x, _ratio_y;
104 |
105 | void logoInit();
106 | void showLogo();
107 |
108 | public:
109 | VideoShow(QWidget *parent);
110 |
111 |
112 | void run(int, int);
113 | void updateSizeVideoFrame();
114 | void changeRatio();
115 | void modeAnaglyph();
116 |
117 | Player * ptrPlayer;
118 |
119 | signals:
120 |
121 | public slots:
122 |
123 | };
124 |
125 | #endif // VIDEOSHOW_H
126 |
--------------------------------------------------------------------------------
/core/ViewThread.cpp:
--------------------------------------------------------------------------------
1 | #include "ViewThread.h"
2 | #include "VideoShow.h"
3 | #include "Player.h"
4 | #include
5 |
6 |
7 | void ViewThread::nextFrame(){
8 | videoShow->update();
9 | }
10 |
11 |
12 | void ViewThread::run(){
13 | timer = new QTimer(this);
14 | // framerate (1000/24 fps)
15 | timer->start(24);
16 | connect(timer, SIGNAL(timeout()), this, SLOT(nextFrame()));
17 | }
18 |
19 | void ViewThread::activeAnaglyph(){
20 | videoShow->modeAnaglyph();
21 | }
22 |
--------------------------------------------------------------------------------
/core/ViewThread.h:
--------------------------------------------------------------------------------
1 | #ifndef VIEWTHREAD_H
2 | #define VIEWTHREAD_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 |
11 |
12 | class VideoShow;
13 | class Player;
14 |
15 | class ViewThread : public QObject {
16 | Q_OBJECT
17 | public:
18 | QPointer glContext;
19 | VideoShow * videoShow;
20 | QTimer * timer;
21 |
22 | ViewThread(VideoShow *video){
23 | videoShow = video;
24 | }
25 | /* stub
26 | void timerEvent(QTimerEvent * ev) {
27 | if (ev->timerId() == timer.timerId()) nextFrame();
28 | }
29 | */
30 | void run();
31 |
32 | signals:
33 | public slots:
34 | void nextFrame();
35 | void activeAnaglyph();
36 | };
37 |
38 | #endif // VIEWTHREAD_H
39 |
40 |
--------------------------------------------------------------------------------
/core/filter.h:
--------------------------------------------------------------------------------
1 | #ifndef FILTER_H
2 | #define FILTER_H
3 |
4 |
5 | class Filter
6 | {
7 | public:
8 | Filter();
9 | };
10 |
11 | #endif // FILTER_H
12 |
--------------------------------------------------------------------------------
/core/main.cpp:
--------------------------------------------------------------------------------
1 | #include "Player.h"
2 | #include
3 |
4 |
5 | int main(int argc, char *argv[]){
6 | QApplication a(argc, argv);
7 | Player w;
8 | w.setAttribute(Qt::WA_TranslucentBackground);
9 | w.show();
10 |
11 | return a.exec();
12 | }
13 |
--------------------------------------------------------------------------------
/forms/player.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Player
4 |
5 |
6 | Qt::NonModal
7 |
8 |
9 |
10 | 0
11 | 0
12 | 800
13 | 620
14 |
15 |
16 |
17 |
18 | 0
19 | 0
20 |
21 |
22 |
23 |
24 | 680
25 | 0
26 |
27 |
28 |
29 |
30 | 1600000
31 | 1600000
32 |
33 |
34 |
35 |
36 | 0
37 | 0
38 |
39 |
40 |
41 |
42 | 800
43 | 620
44 |
45 |
46 |
47 | Qt::NoFocus
48 |
49 |
50 | player
51 |
52 |
53 | 8.000000000000000
54 |
55 |
56 | Qt::LeftToRight
57 |
58 |
59 | false
60 |
61 |
62 | background-color:#fee;
63 |
64 |
65 |
75 |
76 |
77 | TopToolBarArea
78 |
79 |
80 | false
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/logo/1024 Logotype.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SSbug696/OpenGL-media-player.-Libvlc-and-qt/44f8bf97086137ea3131c10cd4c6f307a7c60d55/logo/1024 Logotype.png
--------------------------------------------------------------------------------
/logo/1024 Logotype.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/logo/144 trprant.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/logo/144.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/logo/256 trprant.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/logo/256.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/logo/48 trprant.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/logo/48.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/logo/512 Logotype.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/logo/512 trprant.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/logo/512.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/logo/72 trprant.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/logo/72.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/logo/96 trprant.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/logo/96.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/player.pro:
--------------------------------------------------------------------------------
1 | #-------------------------------------------------
2 | #
3 | # Project created by QtCreator 2015-08-02T01:57:21
4 | #
5 | #-------------------------------------------------
6 |
7 | QT += core gui
8 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
9 | QMAKE_CXXFLAGS+= -std=c++0x -pthread
10 | QMAKE_LFLAGS += -std=c++0x -pthread
11 |
12 | TARGET = player
13 | TEMPLATE = app
14 | LIBS += -lvlc -lglut -lGL -lGLU -lGLEW
15 | QT += opengl
16 | SOURCES += \
17 | core/main.cpp \
18 | core/Instance.cpp \
19 | core/Mediaplayer.cpp \
20 | core/Interface.cpp \
21 | core/Player.cpp \
22 | core/Video.cpp \
23 | core/Media.cpp \
24 | core/Audio.cpp \
25 | widgets/VideoWindow.cpp \
26 | core/DelegateControl.cpp \
27 | core/Filters.cpp \
28 | core/EventsEmitter.cpp \
29 | widgets/ControlPanel.cpp \
30 | core/VideoShow.cpp \
31 | core/ViewThread.cpp \
32 | core/Anaglyph.cpp
33 |
34 | HEADERS += \
35 | core/Instance.h \
36 | core/Mediaplayer.h \
37 | core/Interface.h \
38 | core/Player.h \
39 | core/Video.h \
40 | core/Media.h \
41 | core/Audio.h \
42 | widgets/VideoSlider.h \
43 | widgets/VideoWindow.h \
44 | core/DelegateControl.h \
45 | core/Filters.h \
46 | core/EventsEmitter.h \
47 | core/Options.h \
48 | widgets/ControlPanel.h \
49 | core/VideoShow.h \
50 | core/ViewThread.h \
51 | core/Anaglyph.h \
52 | core/Shaders.h
53 |
54 | FORMS += forms/player.ui
55 | RESOURCES += \
56 |
57 |
58 |
--------------------------------------------------------------------------------
/player.pro.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | EnvironmentId
8 | {e8b03f56-6710-457e-9a7a-1711ed1f9837}
9 |
10 |
11 | ProjectExplorer.Project.ActiveTarget
12 | 1
13 |
14 |
15 | ProjectExplorer.Project.EditorSettings
16 |
17 | true
18 | false
19 | true
20 |
21 | Cpp
22 |
23 | CppGlobal
24 |
25 |
26 |
27 | QmlJS
28 |
29 | QmlJSGlobal
30 |
31 |
32 | 2
33 | UTF-8
34 | false
35 | 4
36 | false
37 | 80
38 | true
39 | true
40 | 1
41 | true
42 | false
43 | 0
44 | true
45 | 0
46 | 8
47 | true
48 | 1
49 | true
50 | true
51 | true
52 | false
53 |
54 |
55 |
56 | ProjectExplorer.Project.PluginSettings
57 |
58 |
59 |
60 | ProjectExplorer.Project.Target.0
61 |
62 | Desktop Qt 5.5.0 GCC 32bit
63 | Desktop Qt 5.5.0 GCC 32bit
64 | qt.55.gcc_kit
65 | 0
66 | 0
67 | 0
68 |
69 | /home/alex/build-player-Desktop_Qt_5_5_0_GCC_32bit-Debug
70 |
71 |
72 | true
73 | qmake
74 |
75 | QtProjectManager.QMakeBuildStep
76 | false
77 | true
78 |
79 | false
80 | false
81 | false
82 |
83 |
84 | true
85 | Сборка
86 |
87 | Qt4ProjectManager.MakeStep
88 |
89 | -w
90 | -r
91 |
92 | false
93 |
94 |
95 |
96 | 2
97 | Сборка
98 |
99 | ProjectExplorer.BuildSteps.Build
100 |
101 |
102 |
103 | true
104 | Сборка
105 |
106 | Qt4ProjectManager.MakeStep
107 |
108 | -w
109 | -r
110 |
111 | true
112 | clean
113 |
114 |
115 | 1
116 | Очистка
117 |
118 | ProjectExplorer.BuildSteps.Clean
119 |
120 | 2
121 | false
122 |
123 | Отладка
124 |
125 | Qt4ProjectManager.Qt4BuildConfiguration
126 | 2
127 | true
128 |
129 |
130 | /home/alex/build-player-Desktop_Qt_5_5_0_GCC_32bit-Release
131 |
132 |
133 | true
134 | qmake
135 |
136 | QtProjectManager.QMakeBuildStep
137 | false
138 | true
139 |
140 | false
141 | false
142 | false
143 |
144 |
145 | true
146 | Сборка
147 |
148 | Qt4ProjectManager.MakeStep
149 |
150 | -w
151 | -r
152 |
153 | false
154 |
155 |
156 |
157 | 2
158 | Сборка
159 |
160 | ProjectExplorer.BuildSteps.Build
161 |
162 |
163 |
164 | true
165 | Сборка
166 |
167 | Qt4ProjectManager.MakeStep
168 |
169 | -w
170 | -r
171 |
172 | true
173 | clean
174 |
175 |
176 | 1
177 | Очистка
178 |
179 | ProjectExplorer.BuildSteps.Clean
180 |
181 | 2
182 | false
183 |
184 | Выпуск
185 |
186 | Qt4ProjectManager.Qt4BuildConfiguration
187 | 0
188 | true
189 |
190 | 2
191 |
192 |
193 | 0
194 | Установка
195 |
196 | ProjectExplorer.BuildSteps.Deploy
197 |
198 | 1
199 | Локальная установка
200 |
201 | ProjectExplorer.DefaultDeployConfiguration
202 |
203 | 1
204 |
205 |
206 |
207 | false
208 | false
209 | false
210 | false
211 | true
212 | 0.01
213 | 10
214 | true
215 | 1
216 | 25
217 |
218 | 1
219 | true
220 | false
221 | true
222 | valgrind
223 |
224 | 0
225 | 1
226 | 2
227 | 3
228 | 4
229 | 5
230 | 6
231 | 7
232 | 8
233 | 9
234 | 10
235 | 11
236 | 12
237 | 13
238 | 14
239 |
240 | 2
241 |
242 | player
243 | player2
244 | Qt4ProjectManager.Qt4RunConfiguration:/var/www/player/player.pro
245 |
246 | player.pro
247 | false
248 | false
249 |
250 | 3768
251 | false
252 | true
253 | false
254 | false
255 | true
256 |
257 | 1
258 |
259 |
260 |
261 | ProjectExplorer.Project.Target.1
262 |
263 | Desktop Qt 5.4.2 GCC 32bit2
264 | Desktop Qt 5.4.2 GCC 32bit2
265 | qt.54.gcc_kit
266 | 1
267 | 0
268 | 0
269 |
270 | /home/alex/build-player-Desktop_Qt_5_4_2_GCC_32bit2-Debug
271 |
272 |
273 | true
274 | qmake
275 |
276 | QtProjectManager.QMakeBuildStep
277 | false
278 | true
279 |
280 | false
281 | false
282 | false
283 |
284 |
285 | true
286 | Сборка
287 |
288 | Qt4ProjectManager.MakeStep
289 |
290 | -w
291 | -r
292 |
293 | false
294 |
295 |
296 |
297 | 2
298 | Сборка
299 |
300 | ProjectExplorer.BuildSteps.Build
301 |
302 |
303 |
304 | true
305 | Сборка
306 |
307 | Qt4ProjectManager.MakeStep
308 |
309 | -w
310 | -r
311 |
312 | true
313 | clean
314 |
315 |
316 | 1
317 | Очистка
318 |
319 | ProjectExplorer.BuildSteps.Clean
320 |
321 | 2
322 | false
323 |
324 | Отладка
325 |
326 | Qt4ProjectManager.Qt4BuildConfiguration
327 | 2
328 | true
329 |
330 |
331 | /home/alex/build-player-Desktop_Qt_5_4_2_GCC_32bit2-Release
332 |
333 |
334 | true
335 | qmake
336 |
337 | QtProjectManager.QMakeBuildStep
338 | false
339 | true
340 |
341 | false
342 | false
343 | false
344 |
345 |
346 | true
347 | Сборка
348 |
349 | Qt4ProjectManager.MakeStep
350 |
351 | -w
352 | -r
353 |
354 | false
355 |
356 |
357 |
358 | 2
359 | Сборка
360 |
361 | ProjectExplorer.BuildSteps.Build
362 |
363 |
364 |
365 | true
366 | Сборка
367 |
368 | Qt4ProjectManager.MakeStep
369 |
370 | -w
371 | -r
372 |
373 | true
374 | clean
375 |
376 |
377 | 1
378 | Очистка
379 |
380 | ProjectExplorer.BuildSteps.Clean
381 |
382 | 2
383 | false
384 |
385 | Выпуск
386 |
387 | Qt4ProjectManager.Qt4BuildConfiguration
388 | 0
389 | true
390 |
391 | 2
392 |
393 |
394 | 0
395 | Установка
396 |
397 | ProjectExplorer.BuildSteps.Deploy
398 |
399 | 1
400 | Локальная установка
401 |
402 | ProjectExplorer.DefaultDeployConfiguration
403 |
404 | 1
405 |
406 |
407 |
408 | false
409 | false
410 | false
411 | false
412 | true
413 | 0.01
414 | 10
415 | true
416 | 1
417 | 25
418 |
419 | 1
420 | true
421 | false
422 | true
423 | valgrind
424 |
425 | 0
426 | 1
427 | 2
428 | 3
429 | 4
430 | 5
431 | 6
432 | 7
433 | 8
434 | 9
435 | 10
436 | 11
437 | 12
438 | 13
439 | 14
440 |
441 | 2
442 |
443 | player
444 | player2
445 | Qt4ProjectManager.Qt4RunConfiguration:/var/www/productive-media-player-3d-anaglyph-/player.pro
446 |
447 | player.pro
448 | false
449 | false
450 |
451 | 3768
452 | false
453 | true
454 | false
455 | false
456 | true
457 |
458 | 1
459 |
460 |
461 |
462 | ProjectExplorer.Project.TargetCount
463 | 2
464 |
465 |
466 | ProjectExplorer.Project.Updater.FileVersion
467 | 18
468 |
469 |
470 | Version
471 | 18
472 |
473 |
474 |
--------------------------------------------------------------------------------
/scheme.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SSbug696/OpenGL-media-player.-Libvlc-and-qt/44f8bf97086137ea3131c10cd4c6f307a7c60d55/scheme.png
--------------------------------------------------------------------------------
/widgets/ControlPanel.cpp:
--------------------------------------------------------------------------------
1 | #include "ControlPanel.h"
2 | #include
3 |
4 |
5 | ControlPanel::ControlPanel(QWidget *parent) : QWidget(parent)
6 | {
7 |
8 | player = parent;
9 | QHBoxLayout *layout = new QHBoxLayout;
10 |
11 | widget = new QWidget(parent);
12 | widget->setGeometry(QRect(20,490, 800, 90));
13 | widget->setAutoFillBackground(true);
14 |
15 | progressSlider = new QSlider(widget);
16 | progressSlider->setSingleStep(1);
17 | progressSlider->setBaseSize(QSize(620, 40));
18 | progressSlider->setOrientation(Qt::Horizontal);
19 | progressSlider->setGeometry(QRect(80, 10, 650,20));
20 |
21 |
22 | volumeLevelSlider = new QSlider(widget);
23 | volumeLevelSlider->setSingleStep(1);
24 | volumeLevelSlider->setOrientation(Qt::Horizontal);
25 | volumeLevelSlider->setBaseSize(QSize(100,10));
26 | volumeLevelSlider->setGeometry(QRect(600, 55, 130, 20));
27 |
28 | startTime= new QLabel(widget);
29 | startTime->setText(QString("00:00"));
30 | startTime->setGeometry(QRect(10, -10, 40, 50));
31 |
32 | finishTime= new QLabel(widget);
33 | finishTime->setText(QString("00:00"));
34 | finishTime->setGeometry(QRect(735, -10, 50, 50));
35 |
36 |
37 | full = new QPushButton(widget);
38 | full->setText(QString("[]"));
39 | full->setGeometry(QRect(40, 50, 40, 30));
40 | full->setStyleSheet(QString("background-color:0xfee;"));
41 |
42 | play = new QPushButton(widget);
43 | play->setText(QString("Play"));
44 | play->setGeometry(QRect(130, 50, 100, 30));
45 | play->setStyleSheet(QString("background-color:0xfee;"));
46 |
47 | pause = new QPushButton(widget);
48 | pause->setText(QString("Pause"));
49 | pause->setGeometry(QRect(235, 50, 100, 30));
50 | pause->setStyleSheet(QString("background-color:0xfee;"));
51 |
52 | ratio = new QPushButton(widget);
53 | ratio->setText(QString("Ratio"));
54 | ratio->setGeometry(QRect(340, 50, 100, 30));
55 | ratio->setStyleSheet(QString("background-color:0xfee;"));
56 |
57 | open = new QPushButton(widget);
58 | open->setText(QString("Select to file"));
59 | open->setGeometry(QRect(460, 50, 120, 30));
60 | open->setStyleSheet(QString("background-color:0xfee"));
61 |
62 |
63 |
64 | QLabel * anaglyph_desc = new QLabel(widget);
65 | anaglyph_desc->setText(QString("Anaglyph"));
66 | anaglyph_desc->setGeometry(QRect(64, 32, 75, 18));
67 |
68 | anaglyph = new QCheckBox(widget);
69 | anaglyph->setText(QString("Anaglyph"));
70 | anaglyph->setGeometry(QRect(85, 60, 20, 15));
71 |
72 | QLabel * mute_desc = new QLabel(widget);
73 | mute_desc->setText(QString("Mute"));
74 | mute_desc->setGeometry(QRect(10, 32, 35, 18));
75 |
76 |
77 | mute = new QCheckBox(widget);
78 | mute->setGeometry(QRect(20, 60, 20, 15));
79 |
80 |
81 | layout->addWidget(widget);
82 | parent->setLayout(layout);
83 | }
84 |
85 |
86 |
--------------------------------------------------------------------------------
/widgets/ControlPanel.h:
--------------------------------------------------------------------------------
1 | #ifndef CONTROLPANEL_H
2 | #define CONTROLPANEL_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 |
12 |
13 | class ControlPanel : public QWidget
14 | {
15 | Q_OBJECT
16 | public:
17 | explicit ControlPanel(QWidget *parent = 0);
18 | QWidget * player;
19 | QWidget * widget;
20 |
21 | QSlider * progressSlider;
22 | QSlider * volumeLevelSlider;
23 | QLabel * startTime;
24 | QLabel * finishTime;
25 |
26 | QPushButton * play;
27 | QPushButton * full;
28 | QPushButton * ratio;
29 | QPushButton * pause;
30 | QPushButton * open;
31 | QCheckBox * anaglyph;
32 | QCheckBox * mute;
33 | QVBoxLayout * box;
34 |
35 | signals:
36 |
37 | public slots:
38 | };
39 |
40 | #endif // CONTROLPANEL_H
41 |
--------------------------------------------------------------------------------
/widgets/VideoSlider.cpp:
--------------------------------------------------------------------------------
1 | #include "VideoSlider.h"
2 | #include
3 | #include
4 | #include
5 |
6 |
7 | VideoSlider::VideoSlider(QWidget *parent) : QWidget(parent)
8 | {
9 | /*
10 | sliderVideo = new QSlider(parent);
11 | sliderVideo->setOrientation(Qt::Horizontal);
12 | sliderVideo->setGeometry(QRect(90, 490, 531, 29));
13 | sliderVideo->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
14 | sliderVideo->setMaximum(100);
15 | sliderVideo->setRange(0, 1000);
16 | sliderVideo->setPageStep(1);
17 | sliderVideo->setPageStep(1);
18 |
19 | sliderVideo->show();
20 | */
21 | /*
22 | QLabel *p = new QLabel(parent);
23 | p->setText(QString("i love you!)"));
24 | p->move(QPoint(200, 540));
25 | p->show();
26 | */
27 | }
28 |
29 |
--------------------------------------------------------------------------------
/widgets/VideoSlider.h:
--------------------------------------------------------------------------------
1 | #ifndef VIDEOSLIDER_H
2 | #define VIDEOSLIDER_H
3 | #include
4 |
5 |
6 | class QSlider;
7 |
8 | class VideoSlider : public QWidget
9 | {
10 | Q_OBJECT
11 | public:
12 | explicit VideoSlider(QWidget *parent = 0);
13 | QSlider * sliderVideo;
14 |
15 | signals:
16 |
17 | public slots:
18 | };
19 |
20 | #endif // VIDEOSLIDER_H
21 |
--------------------------------------------------------------------------------
/widgets/VideoWindow.cpp:
--------------------------------------------------------------------------------
1 | #include "VideoWindow.h"
2 | #if QT_VERSION >= 0x050000
3 | #include
4 | #include
5 | #include
6 | #include
7 | #else
8 | #include
9 | #include
10 | #include
11 | #include
12 | #endif
13 |
14 | #if defined(Q_WS_X11)
15 | #include
16 | #include
17 | #endif
18 | #include
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 |
28 |
29 | VideoWindow::VideoWindow(QWidget *parent) : QWidget(parent)
30 | {
31 |
32 | QHBoxLayout *layout = new QHBoxLayout;
33 | videoWindow = new QWidget(parent);
34 | videoWindow->setGeometry(0, 0, 800, 490);
35 | videoWindow->setBaseSize(QSize(800, 490));
36 | videoWindow->setMouseTracking(true);
37 | videoWindow->setStyleSheet(QString("background-color: #000;width:100%;height:100%;"));
38 | videoWindow->setAutoFillBackground(true);
39 | // videoWindow-> //setStretchFactor(0, 100);
40 | //videoWindow->show();
41 | layout->addWidget(videoWindow);
42 | layout->setStretch(1, 0);
43 | parent->setLayout(layout);
44 |
45 |
46 |
47 |
48 | #ifndef Q_WS_X11
49 | videoWindow->setAttribute( Qt::WA_PaintOnScreen, false );
50 | #endif
51 |
52 |
53 | }
54 |
55 |
--------------------------------------------------------------------------------
/widgets/VideoWindow.h:
--------------------------------------------------------------------------------
1 | #ifndef VIDEOFRAME_H
2 | #define VIDEOFRAME_H
3 | #include
4 |
5 |
6 | class VideoWindow : public QWidget
7 | {
8 | Q_OBJECT
9 | public:
10 | explicit VideoWindow(QWidget *parent = 0);
11 | QWidget * videoWindow;
12 | signals:
13 |
14 | public slots:
15 | };
16 |
17 | #endif // VIDEOFRAME_H
18 |
--------------------------------------------------------------------------------