diff options
author | Jacek Antonelli | 2009-04-06 01:32:42 -0500 |
---|---|---|
committer | Jacek Antonelli | 2009-04-06 01:34:44 -0500 |
commit | f3d08c4bed781ea455f0b60ebc294423eb559025 (patch) | |
tree | d13d3f52eb783ad43a26ff6f09b1b99b7970bd2a | |
parent | Merge commit 'mccabe/gst-revamp' into gst-revamp (diff) | |
parent | LLMediaImplGStreamer creates new thread for playing. (diff) | |
download | meta-impy-f3d08c4bed781ea455f0b60ebc294423eb559025.zip meta-impy-f3d08c4bed781ea455f0b60ebc294423eb559025.tar.gz meta-impy-f3d08c4bed781ea455f0b60ebc294423eb559025.tar.bz2 meta-impy-f3d08c4bed781ea455f0b60ebc294423eb559025.tar.xz |
Merge branch gst-thread into gst-revamp
Conflicts:
linden/indra/llmedia/llmediaimplgstreamer.cpp
-rw-r--r-- | ChangeLog.txt | 23 | ||||
-rw-r--r-- | linden/indra/llmedia/CMakeLists.txt | 2 | ||||
-rw-r--r-- | linden/indra/llmedia/llgstplaythread.cpp | 54 | ||||
-rw-r--r-- | linden/indra/llmedia/llgstplaythread.h | 62 | ||||
-rw-r--r-- | linden/indra/llmedia/llmediaimplgstreamer.cpp | 36 | ||||
-rw-r--r-- | linden/indra/llmedia/llmediaimplgstreamer.h | 6 |
6 files changed, 175 insertions, 8 deletions
diff --git a/ChangeLog.txt b/ChangeLog.txt index a4c3415..f99ebae 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt | |||
@@ -1,3 +1,26 @@ | |||
1 | 2009-04-05 Jacek Antonelli <jacek.antonelli@gmail.com> | ||
2 | |||
3 | * linden/indra/llmedia/llmediaimplgstreamer.cpp: | ||
4 | LLMediaImplGStreamer creates new thread for playing. | ||
5 | This keeps the viewer responsive while GStreamer does its thing. | ||
6 | * linden/indra/llmedia/llmediaimplgstreamer.h: | ||
7 | Ditto. | ||
8 | |||
9 | |||
10 | * linden/indra/llmedia/llgstplaythread.cpp: | ||
11 | Added LLGstPlayThread class. | ||
12 | * linden/indra/llmedia/llgstplaythread.h: | ||
13 | Ditto. | ||
14 | * linden/indra/llmedia/CMakeLists.txt: | ||
15 | Ditto. | ||
16 | |||
17 | |||
18 | 2009-04-04 Jacek Antonelli <jacek.antonelli@gmail.com> | ||
19 | |||
20 | * linden/indra/llmedia/llmediaimplgstreamer.cpp: | ||
21 | Refactored the heart of the GST play code to startPlay(). | ||
22 | |||
23 | |||
1 | 2009-04-02 Jacek Antonelli <jacek.antonelli@gmail.com> | 24 | 2009-04-02 Jacek Antonelli <jacek.antonelli@gmail.com> |
2 | 25 | ||
3 | * linden/indra/newview/llviewermedia.cpp: | 26 | * linden/indra/newview/llviewermedia.cpp: |
diff --git a/linden/indra/llmedia/CMakeLists.txt b/linden/indra/llmedia/CMakeLists.txt index 0440153..0e5b261 100644 --- a/linden/indra/llmedia/CMakeLists.txt +++ b/linden/indra/llmedia/CMakeLists.txt | |||
@@ -31,6 +31,7 @@ set(llmedia_SOURCE_FILES | |||
31 | llmediamanager.cpp | 31 | llmediamanager.cpp |
32 | llmediaimplgstreamer.cpp | 32 | llmediaimplgstreamer.cpp |
33 | llmediaimplgstreamervidplug.cpp | 33 | llmediaimplgstreamervidplug.cpp |
34 | llgstplaythread.cpp | ||
34 | ) | 35 | ) |
35 | 36 | ||
36 | set(llmedia_HEADER_FILES | 37 | set(llmedia_HEADER_FILES |
@@ -47,6 +48,7 @@ set(llmedia_HEADER_FILES | |||
47 | llmediaobserver.h | 48 | llmediaobserver.h |
48 | llmediaimplgstreamer.h | 49 | llmediaimplgstreamer.h |
49 | llmediaimplgstreamervidplug.h | 50 | llmediaimplgstreamervidplug.h |
51 | llgstplaythread.h | ||
50 | ) | 52 | ) |
51 | 53 | ||
52 | # Work around a bad interaction between broken gstreamer headers and | 54 | # Work around a bad interaction between broken gstreamer headers and |
diff --git a/linden/indra/llmedia/llgstplaythread.cpp b/linden/indra/llmedia/llgstplaythread.cpp new file mode 100644 index 0000000..152f9d9 --- /dev/null +++ b/linden/indra/llmedia/llgstplaythread.cpp | |||
@@ -0,0 +1,54 @@ | |||
1 | /** | ||
2 | * @file llgstplaythread.cpp | ||
3 | * @author Jacek Antonelli | ||
4 | * @brief GStreamer playback management thread class | ||
5 | * | ||
6 | * $LicenseInfo:firstyear=2009&license=viewergpl$ | ||
7 | * | ||
8 | * Copyright (c) 2009, Jacek Antonelli | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or | ||
11 | * modify it under the terms of version 2 of the GNU General Public | ||
12 | * License as published by the Free Software Foundation. Terms of | ||
13 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
14 | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
15 | * | ||
16 | * There are special exceptions to the terms and conditions of the GPL as | ||
17 | * it is applied to this Source Code. View the full text of the exception | ||
18 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
19 | * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
20 | * | ||
21 | * This program is distributed in the hope that it will be useful, | ||
22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
24 | * GNU General Public License for more details. | ||
25 | * | ||
26 | * You should have received a copy of the GNU General Public License along | ||
27 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
28 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
29 | * | ||
30 | * $/LicenseInfo$ | ||
31 | */ | ||
32 | |||
33 | #include "llgstplaythread.h" | ||
34 | #include "llmediaimplgstreamer.h" | ||
35 | |||
36 | LLGstPlayThread:: | ||
37 | LLGstPlayThread( LLMediaImplCommon *impl, | ||
38 | const std::string& name, apr_pool_t *poolp ): | ||
39 | LLThread( name, poolp ), | ||
40 | mMediaImpl( impl ) | ||
41 | { | ||
42 | } | ||
43 | |||
44 | |||
45 | LLGstPlayThread::~LLGstPlayThread() | ||
46 | { | ||
47 | } | ||
48 | |||
49 | |||
50 | // virtual | ||
51 | void LLGstPlayThread::run() | ||
52 | { | ||
53 | ((LLMediaImplGStreamer *)mMediaImpl)->startPlay(); | ||
54 | } | ||
diff --git a/linden/indra/llmedia/llgstplaythread.h b/linden/indra/llmedia/llgstplaythread.h new file mode 100644 index 0000000..c3c36a7 --- /dev/null +++ b/linden/indra/llmedia/llgstplaythread.h | |||
@@ -0,0 +1,62 @@ | |||
1 | /** | ||
2 | * @file llgstplaythread.h | ||
3 | * @author Jacek Antonelli | ||
4 | * @brief GStreamer playback management thread class | ||
5 | * | ||
6 | * $LicenseInfo:firstyear=2009&license=viewergpl$ | ||
7 | * | ||
8 | * Copyright (c) 2009, Jacek Antonelli | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or | ||
11 | * modify it under the terms of version 2 of the GNU General Public | ||
12 | * License as published by the Free Software Foundation. Terms of | ||
13 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
14 | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
15 | * | ||
16 | * There are special exceptions to the terms and conditions of the GPL as | ||
17 | * it is applied to this Source Code. View the full text of the exception | ||
18 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
19 | * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
20 | * | ||
21 | * This program is distributed in the hope that it will be useful, | ||
22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
24 | * GNU General Public License for more details. | ||
25 | * | ||
26 | * You should have received a copy of the GNU General Public License along | ||
27 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
28 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
29 | * | ||
30 | * $/LicenseInfo$ | ||
31 | */ | ||
32 | |||
33 | |||
34 | #ifndef LL_LLGSTPLAYTHREAD_H | ||
35 | #define LL_LLGSTPLAYTHREAD_H | ||
36 | |||
37 | #include "linden_common.h" | ||
38 | |||
39 | #include "llthread.h" | ||
40 | #include "llmediaimplcommon.h" | ||
41 | |||
42 | class LLGstPlayThread: public LLThread | ||
43 | { | ||
44 | public: | ||
45 | |||
46 | LLGstPlayThread( LLMediaImplCommon *impl, | ||
47 | const std::string& name, apr_pool_t *poolp ); | ||
48 | |||
49 | ~LLGstPlayThread(); | ||
50 | |||
51 | virtual void run(); | ||
52 | |||
53 | private: | ||
54 | |||
55 | // Actually, this will really only be an LLMediaImplGStreamer. | ||
56 | // But we have to jump through some hoops to mutual pointer-holding. | ||
57 | // There may be a better way, but I don't have the motivation to find it. | ||
58 | LLMediaImplCommon *mMediaImpl; | ||
59 | }; | ||
60 | |||
61 | |||
62 | #endif // LL_LLGSTPLAYTHREAD_H | ||
diff --git a/linden/indra/llmedia/llmediaimplgstreamer.cpp b/linden/indra/llmedia/llmediaimplgstreamer.cpp index 271bb5e..7ae6b02 100644 --- a/linden/indra/llmedia/llmediaimplgstreamer.cpp +++ b/linden/indra/llmedia/llmediaimplgstreamer.cpp | |||
@@ -39,6 +39,7 @@ | |||
39 | #pragma warning(disable : 4244) | 39 | #pragma warning(disable : 4244) |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | #include "linden_common.h" | ||
42 | #include "llmediaimplgstreamer.h" | 43 | #include "llmediaimplgstreamer.h" |
43 | 44 | ||
44 | extern "C" { | 45 | extern "C" { |
@@ -56,9 +57,8 @@ extern "C" { | |||
56 | #include "llmediaimplregister.h" | 57 | #include "llmediaimplregister.h" |
57 | 58 | ||
58 | #include "llmediaimplgstreamervidplug.h" | 59 | #include "llmediaimplgstreamervidplug.h" |
60 | #include "llgstplaythread.h" | ||
59 | 61 | ||
60 | #include "llerror.h" | ||
61 | #include "linden_common.h" | ||
62 | 62 | ||
63 | // register this impl with media manager factory | 63 | // register this impl with media manager factory |
64 | static LLMediaImplRegister sLLMediaImplGStreamerReg( "LLMediaImplGStreamer", new LLMediaImplGStreamerMaker() ); | 64 | static LLMediaImplRegister sLLMediaImplGStreamerReg( "LLMediaImplGStreamer", new LLMediaImplGStreamerMaker() ); |
@@ -85,7 +85,8 @@ LLMediaImplGStreamer () : | |||
85 | mPump ( NULL ), | 85 | mPump ( NULL ), |
86 | mPlaybin ( NULL ), | 86 | mPlaybin ( NULL ), |
87 | mVideoSink ( NULL ), | 87 | mVideoSink ( NULL ), |
88 | mState( GST_STATE_NULL ) | 88 | mState( GST_STATE_NULL ), |
89 | mPlayThread ( NULL ) | ||
89 | { | 90 | { |
90 | startup( NULL ); // Startup gstreamer if it hasn't been already. | 91 | startup( NULL ); // Startup gstreamer if it hasn't been already. |
91 | 92 | ||
@@ -737,6 +738,30 @@ bool LLMediaImplGStreamer::play() | |||
737 | if (!mPlaybin || mState == GST_STATE_NULL) | 738 | if (!mPlaybin || mState == GST_STATE_NULL) |
738 | return true; | 739 | return true; |
739 | 740 | ||
741 | // Clean up the existing thread, if any. | ||
742 | if( mPlayThread != NULL && mPlayThread->isStopped()) | ||
743 | { | ||
744 | delete mPlayThread; | ||
745 | mPlayThread = NULL; | ||
746 | } | ||
747 | |||
748 | if( mPlayThread == NULL ) | ||
749 | { | ||
750 | // Make a new thread to start playing. This keeps the viewer | ||
751 | // responsive while the stream is resolved and buffered. | ||
752 | mPlayThread = new LLGstPlayThread( (LLMediaImplCommon *)this, "GstPlayThread", NULL); | ||
753 | mPlayThread->start(); | ||
754 | } | ||
755 | |||
756 | return true; | ||
757 | } | ||
758 | |||
759 | |||
760 | void LLMediaImplGStreamer::startPlay() | ||
761 | { | ||
762 | GstElement *pipeline = (GstElement *)gst_object_ref(GST_OBJECT(mPlaybin)); | ||
763 | gst_object_unref(pipeline); | ||
764 | |||
740 | GstStateChangeReturn state_change; | 765 | GstStateChangeReturn state_change; |
741 | 766 | ||
742 | state_change = gst_element_set_state(mPlaybin, GST_STATE_PLAYING); | 767 | state_change = gst_element_set_state(mPlaybin, GST_STATE_PLAYING); |
@@ -753,11 +778,6 @@ bool LLMediaImplGStreamer::play() | |||
753 | // We also force a stop in case the operations don't sync | 778 | // We also force a stop in case the operations don't sync |
754 | setStatus(LLMediaBase::STATUS_UNKNOWN); | 779 | setStatus(LLMediaBase::STATUS_UNKNOWN); |
755 | stop(); | 780 | stop(); |
756 | return false; | ||
757 | } | ||
758 | else | ||
759 | { | ||
760 | return true; | ||
761 | } | 781 | } |
762 | } | 782 | } |
763 | 783 | ||
diff --git a/linden/indra/llmedia/llmediaimplgstreamer.h b/linden/indra/llmedia/llmediaimplgstreamer.h index 37eaf53..32e6bd1 100644 --- a/linden/indra/llmedia/llmediaimplgstreamer.h +++ b/linden/indra/llmedia/llmediaimplgstreamer.h | |||
@@ -48,6 +48,7 @@ extern "C" { | |||
48 | } | 48 | } |
49 | 49 | ||
50 | #include "llmediaimplgstreamervidplug.h" | 50 | #include "llmediaimplgstreamervidplug.h" |
51 | #include "llgstplaythread.h" | ||
51 | 52 | ||
52 | class LLMediaManagerData; | 53 | class LLMediaManagerData; |
53 | class LLMediaImplMaker; | 54 | class LLMediaImplMaker; |
@@ -96,6 +97,9 @@ class LLMediaImplGStreamer: | |||
96 | /* virtual */ bool seek( double time ); | 97 | /* virtual */ bool seek( double time ); |
97 | /* virtual */ bool setVolume( float volume ); | 98 | /* virtual */ bool setVolume( float volume ); |
98 | 99 | ||
100 | void startPlay(); | ||
101 | |||
102 | |||
99 | LLMediaEmitter< LLMediaObserver > getEventEmitter() const {return mEventEmitter;}; | 103 | LLMediaEmitter< LLMediaObserver > getEventEmitter() const {return mEventEmitter;}; |
100 | 104 | ||
101 | private: | 105 | private: |
@@ -121,6 +125,8 @@ class LLMediaImplGStreamer: | |||
121 | GstSLVideo *mVideoSink; | 125 | GstSLVideo *mVideoSink; |
122 | GstState mState; | 126 | GstState mState; |
123 | GstState getState() const { return mState; } | 127 | GstState getState() const { return mState; } |
128 | |||
129 | LLGstPlayThread *mPlayThread; | ||
124 | }; | 130 | }; |
125 | 131 | ||
126 | class LLMediaImplGStreamerMaker : public LLMediaImplMaker | 132 | class LLMediaImplGStreamerMaker : public LLMediaImplMaker |