diff options
Diffstat (limited to 'linden/indra/media_plugins/gstreamer010')
4 files changed, 69 insertions, 52 deletions
diff --git a/linden/indra/media_plugins/gstreamer010/llmediaimplgstreamertriviallogging.h b/linden/indra/media_plugins/gstreamer010/llmediaimplgstreamertriviallogging.h index e31d4a3..04976b9 100644 --- a/linden/indra/media_plugins/gstreamer010/llmediaimplgstreamertriviallogging.h +++ b/linden/indra/media_plugins/gstreamer010/llmediaimplgstreamertriviallogging.h | |||
@@ -35,10 +35,16 @@ | |||
35 | 35 | ||
36 | #include <cstdio> | 36 | #include <cstdio> |
37 | 37 | ||
38 | extern "C" { | ||
39 | #include <sys/types.h> | ||
40 | #include <unistd.h> | ||
41 | } | ||
42 | |||
38 | ///////////////////////////////////////////////////////////////////////// | 43 | ///////////////////////////////////////////////////////////////////////// |
39 | // Debug/Info/Warning macros. | 44 | // Debug/Info/Warning macros. |
40 | #define MSGMODULEFOO "(media plugin)" | 45 | #define MSGMODULEFOO "(media plugin)" |
41 | #define STDERRMSG(...) do{\ | 46 | #define STDERRMSG(...) do{\ |
47 | fprintf(stderr, " pid:%d: ", (int)getpid());\ | ||
42 | fprintf(stderr, MSGMODULEFOO " %s:%d: ", __FUNCTION__, __LINE__);\ | 48 | fprintf(stderr, MSGMODULEFOO " %s:%d: ", __FUNCTION__, __LINE__);\ |
43 | fprintf(stderr, __VA_ARGS__);\ | 49 | fprintf(stderr, __VA_ARGS__);\ |
44 | fputc('\n',stderr);\ | 50 | fputc('\n',stderr);\ |
diff --git a/linden/indra/media_plugins/gstreamer010/llmediaimplgstreamervidplug.cpp b/linden/indra/media_plugins/gstreamer010/llmediaimplgstreamervidplug.cpp index 25e96d4..ef8ff58 100644 --- a/linden/indra/media_plugins/gstreamer010/llmediaimplgstreamervidplug.cpp +++ b/linden/indra/media_plugins/gstreamer010/llmediaimplgstreamervidplug.cpp | |||
@@ -52,7 +52,7 @@ GST_DEBUG_CATEGORY_STATIC (gst_slvideo_debug); | |||
52 | #define SLV_ALLCAPS GST_VIDEO_CAPS_RGBx SLV_SIZECAPS | 52 | #define SLV_ALLCAPS GST_VIDEO_CAPS_RGBx SLV_SIZECAPS |
53 | 53 | ||
54 | static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ( | 54 | static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ( |
55 | (gchar*)"sink", | 55 | "sink", |
56 | GST_PAD_SINK, | 56 | GST_PAD_SINK, |
57 | GST_PAD_ALWAYS, | 57 | GST_PAD_ALWAYS, |
58 | GST_STATIC_CAPS (SLV_ALLCAPS) | 58 | GST_STATIC_CAPS (SLV_ALLCAPS) |
@@ -106,11 +106,10 @@ gst_slvideo_show_frame (GstBaseSink * bsink, GstBuffer * buf) | |||
106 | 106 | ||
107 | slvideo = GST_SLVIDEO(bsink); | 107 | slvideo = GST_SLVIDEO(bsink); |
108 | 108 | ||
109 | #if 0 | 109 | DEBUGMSG("transferring a frame of %dx%d <- %p (%d)", |
110 | fprintf(stderr, "\n\ntransferring a frame of %dx%d <- %p (%d)\n\n", | 110 | slvideo->width, slvideo->height, GST_BUFFER_DATA(buf), |
111 | slvideo->width, slvideo->height, GST_BUFFER_DATA(buf), | 111 | slvideo->format); |
112 | slvideo->format); | 112 | |
113 | #endif | ||
114 | if (GST_BUFFER_DATA(buf)) | 113 | if (GST_BUFFER_DATA(buf)) |
115 | { | 114 | { |
116 | // copy frame and frame info into neutral territory | 115 | // copy frame and frame info into neutral territory |
@@ -335,7 +334,7 @@ gst_slvideo_buffer_alloc (GstBaseSink * bsink, guint64 offset, guint size, | |||
335 | #define MAXDEPTHHACK 4 | 334 | #define MAXDEPTHHACK 4 |
336 | 335 | ||
337 | GST_OBJECT_LOCK(slvideo); | 336 | GST_OBJECT_LOCK(slvideo); |
338 | if (slvideo->resize_forced) | 337 | if (slvideo->resize_forced_always) // app is giving us a fixed size to work with |
339 | { | 338 | { |
340 | gint slwantwidth, slwantheight; | 339 | gint slwantwidth, slwantheight; |
341 | slwantwidth = slvideo->resize_try_width; | 340 | slwantwidth = slvideo->resize_try_width; |
@@ -384,6 +383,8 @@ gst_slvideo_buffer_alloc (GstBaseSink * bsink, guint64 offset, guint size, | |||
384 | } | 383 | } |
385 | } | 384 | } |
386 | 385 | ||
386 | GST_OBJECT_UNLOCK(slvideo); | ||
387 | |||
387 | if (!made_bufferdata_ptr) // need to fallback to malloc at original size | 388 | if (!made_bufferdata_ptr) // need to fallback to malloc at original size |
388 | { | 389 | { |
389 | GST_BUFFER_SIZE(newbuf) = width * height * MAXDEPTHHACK; | 390 | GST_BUFFER_SIZE(newbuf) = width * height * MAXDEPTHHACK; |
@@ -392,8 +393,6 @@ gst_slvideo_buffer_alloc (GstBaseSink * bsink, guint64 offset, guint size, | |||
392 | llgst_buffer_set_caps (GST_BUFFER_CAST(newbuf), caps); | 393 | llgst_buffer_set_caps (GST_BUFFER_CAST(newbuf), caps); |
393 | } | 394 | } |
394 | 395 | ||
395 | GST_OBJECT_UNLOCK(slvideo); | ||
396 | |||
397 | *buf = GST_BUFFER_CAST(newbuf); | 396 | *buf = GST_BUFFER_CAST(newbuf); |
398 | 397 | ||
399 | return GST_FLOW_OK; | 398 | return GST_FLOW_OK; |
@@ -457,7 +456,7 @@ gst_slvideo_init (GstSLVideo * filter, | |||
457 | filter->retained_frame_format = SLV_PF_UNKNOWN; | 456 | filter->retained_frame_format = SLV_PF_UNKNOWN; |
458 | GstCaps *caps = llgst_caps_from_string (SLV_ALLCAPS); | 457 | GstCaps *caps = llgst_caps_from_string (SLV_ALLCAPS); |
459 | llgst_caps_replace (&filter->caps, caps); | 458 | llgst_caps_replace (&filter->caps, caps); |
460 | filter->resize_forced = false; | 459 | filter->resize_forced_always = false; |
461 | filter->resize_try_width = -1; | 460 | filter->resize_try_width = -1; |
462 | filter->resize_try_height = -1; | 461 | filter->resize_try_height = -1; |
463 | GST_OBJECT_UNLOCK(filter); | 462 | GST_OBJECT_UNLOCK(filter); |
@@ -498,12 +497,12 @@ gst_slvideo_get_property (GObject * object, guint prop_id, | |||
498 | static gboolean | 497 | static gboolean |
499 | plugin_init (GstPlugin * plugin) | 498 | plugin_init (GstPlugin * plugin) |
500 | { | 499 | { |
501 | DEBUGMSG("\n\n\nPLUGIN INIT\n\n\n"); | 500 | DEBUGMSG("PLUGIN INIT"); |
502 | 501 | ||
503 | GST_DEBUG_CATEGORY_INIT (gst_slvideo_debug, (gchar*)"private-slvideo-plugin", | 502 | GST_DEBUG_CATEGORY_INIT (gst_slvideo_debug, (gchar*)"private-slvideo-plugin", |
504 | 0, (gchar*)"Second Life Video Sink"); | 503 | 0, (gchar*)"Second Life Video Sink"); |
505 | 504 | ||
506 | return llgst_element_register (plugin, (gchar*)"private-slvideo", | 505 | return llgst_element_register (plugin, "private-slvideo", |
507 | GST_RANK_NONE, GST_TYPE_SLVIDEO); | 506 | GST_RANK_NONE, GST_TYPE_SLVIDEO); |
508 | } | 507 | } |
509 | 508 | ||
@@ -519,14 +518,14 @@ void gst_slvideo_init_class (void) | |||
519 | // this macro quietly refers to PACKAGE internally | 518 | // this macro quietly refers to PACKAGE internally |
520 | static GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, | 519 | static GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, |
521 | GST_VERSION_MINOR, | 520 | GST_VERSION_MINOR, |
522 | (gchar*)"private-slvideoplugin", | 521 | "private-slvideoplugin", |
523 | (gchar*)"SL Video sink plugin", | 522 | "SL Video sink plugin", |
524 | plugin_init, (gchar*)"0.1", (gchar*)GST_LICENSE_UNKNOWN, | 523 | plugin_init, "0.1", GST_LICENSE_UNKNOWN, |
525 | (gchar*)"Second Life", | 524 | "Second Life", |
526 | (gchar*)"http://www.secondlife.com/"); | 525 | "http://www.secondlife.com/"); |
527 | #undef PACKAGE | 526 | #undef PACKAGE |
528 | ll_gst_plugin_register_static (&gst_plugin_desc); | 527 | ll_gst_plugin_register_static (&gst_plugin_desc); |
529 | DEBUGMSG(stderr, "\n\n\nCLASS INIT\n\n\n"); | 528 | DEBUGMSG("CLASS INIT"); |
530 | } | 529 | } |
531 | 530 | ||
532 | #endif // LL_GSTREAMER010_ENABLED | 531 | #endif // LL_GSTREAMER010_ENABLED |
diff --git a/linden/indra/media_plugins/gstreamer010/llmediaimplgstreamervidplug.h b/linden/indra/media_plugins/gstreamer010/llmediaimplgstreamervidplug.h index f6d55b8..8cdc72d 100644 --- a/linden/indra/media_plugins/gstreamer010/llmediaimplgstreamervidplug.h +++ b/linden/indra/media_plugins/gstreamer010/llmediaimplgstreamervidplug.h | |||
@@ -88,7 +88,7 @@ struct _GstSLVideo | |||
88 | int retained_frame_width, retained_frame_height; | 88 | int retained_frame_width, retained_frame_height; |
89 | SLVPixelFormat retained_frame_format; | 89 | SLVPixelFormat retained_frame_format; |
90 | // sticky resize info | 90 | // sticky resize info |
91 | bool resize_forced; | 91 | bool resize_forced_always; |
92 | int resize_try_width; | 92 | int resize_try_width; |
93 | int resize_try_height; | 93 | int resize_try_height; |
94 | }; | 94 | }; |
diff --git a/linden/indra/media_plugins/gstreamer010/media_plugin_gstreamer010.cpp b/linden/indra/media_plugins/gstreamer010/media_plugin_gstreamer010.cpp index 77b7c13..5b3152d 100644 --- a/linden/indra/media_plugins/gstreamer010/media_plugin_gstreamer010.cpp +++ b/linden/indra/media_plugins/gstreamer010/media_plugin_gstreamer010.cpp | |||
@@ -104,7 +104,7 @@ private: | |||
104 | void mouseUp( int x, int y ); | 104 | void mouseUp( int x, int y ); |
105 | void mouseMove( int x, int y ); | 105 | void mouseMove( int x, int y ); |
106 | 106 | ||
107 | bool sizeChanged(); | 107 | void sizeChanged(); |
108 | 108 | ||
109 | static bool mDoneInit; | 109 | static bool mDoneInit; |
110 | 110 | ||
@@ -114,13 +114,16 @@ private: | |||
114 | 114 | ||
115 | int mDepth; | 115 | int mDepth; |
116 | 116 | ||
117 | // media natural size | 117 | // media NATURAL size |
118 | int mNaturalWidth; | 118 | int mNaturalWidth; |
119 | int mNaturalHeight; | 119 | int mNaturalHeight; |
120 | int mNaturalRowbytes; | 120 | // media current size |
121 | // previous media natural size so we can detect changes | 121 | int mCurrentWidth; |
122 | int mPreviousNaturalWidth; | 122 | int mCurrentHeight; |
123 | int mPreviousNaturalHeight; | 123 | int mCurrentRowbytes; |
124 | // previous media size so we can detect changes | ||
125 | int mPreviousWidth; | ||
126 | int mPreviousHeight; | ||
124 | // desired render size from host | 127 | // desired render size from host |
125 | int mWidth; | 128 | int mWidth; |
126 | int mHeight; | 129 | int mHeight; |
@@ -148,7 +151,7 @@ MediaPluginGStreamer010::MediaPluginGStreamer010( | |||
148 | void *host_user_data ) : | 151 | void *host_user_data ) : |
149 | MediaPluginBase(host_send_func, host_user_data), | 152 | MediaPluginBase(host_send_func, host_user_data), |
150 | mBusWatchID ( 0 ), | 153 | mBusWatchID ( 0 ), |
151 | mNaturalRowbytes ( 4 ), | 154 | mCurrentRowbytes ( 4 ), |
152 | mTextureFormatPrimary ( GL_RGBA ), | 155 | mTextureFormatPrimary ( GL_RGBA ), |
153 | mTextureFormatType ( GL_UNSIGNED_INT_8_8_8_8_REV ), | 156 | mTextureFormatType ( GL_UNSIGNED_INT_8_8_8_8_REV ), |
154 | mSeekWanted(false), | 157 | mSeekWanted(false), |
@@ -194,6 +197,7 @@ MediaPluginGStreamer010::processGSTEvents(GstBus *bus, | |||
194 | } | 197 | } |
195 | else | 198 | else |
196 | { | 199 | { |
200 | // TODO: grok 'duration' message type | ||
197 | DEBUGMSG("Got GST message type: %s", | 201 | DEBUGMSG("Got GST message type: %s", |
198 | LLGST_MESSAGE_TYPE_NAME (message)); | 202 | LLGST_MESSAGE_TYPE_NAME (message)); |
199 | } | 203 | } |
@@ -428,8 +432,8 @@ MediaPluginGStreamer010::update(int milliseconds) | |||
428 | { | 432 | { |
429 | DEBUGMSG("NEW FRAME READY"); | 433 | DEBUGMSG("NEW FRAME READY"); |
430 | 434 | ||
431 | if (mVideoSink->retained_frame_width != mNaturalWidth || | 435 | if (mVideoSink->retained_frame_width != mCurrentWidth || |
432 | mVideoSink->retained_frame_height != mNaturalHeight) | 436 | mVideoSink->retained_frame_height != mCurrentHeight) |
433 | // *TODO: also check for change in format | 437 | // *TODO: also check for change in format |
434 | { | 438 | { |
435 | // just resize container, don't consume frame | 439 | // just resize container, don't consume frame |
@@ -456,39 +460,38 @@ MediaPluginGStreamer010::update(int milliseconds) | |||
456 | 460 | ||
457 | GST_OBJECT_UNLOCK(mVideoSink); | 461 | GST_OBJECT_UNLOCK(mVideoSink); |
458 | 462 | ||
459 | mNaturalRowbytes = neww * newd; | 463 | mCurrentRowbytes = neww * newd; |
460 | DEBUGMSG("video container resized to %dx%d", | 464 | DEBUGMSG("video container resized to %dx%d", |
461 | neww, newh); | 465 | neww, newh); |
462 | 466 | ||
463 | mDepth = newd; | 467 | mDepth = newd; |
464 | mNaturalWidth = neww; | 468 | mCurrentWidth = neww; |
465 | mNaturalHeight = newh; | 469 | mCurrentHeight = newh; |
466 | sizeChanged(); | 470 | sizeChanged(); |
467 | return true; | 471 | return true; |
468 | } | 472 | } |
469 | 473 | ||
470 | if (mPixels && | 474 | if (mPixels && |
471 | mNaturalHeight <= mHeight && | 475 | mCurrentHeight <= mHeight && |
472 | mNaturalWidth <= mWidth && | 476 | mCurrentWidth <= mWidth && |
473 | !mTextureSegmentName.empty()) | 477 | !mTextureSegmentName.empty()) |
474 | { | 478 | { |
475 | |||
476 | // we're gonna totally consume this frame - reset 'ready' flag | 479 | // we're gonna totally consume this frame - reset 'ready' flag |
477 | mVideoSink->retained_frame_ready = FALSE; | 480 | mVideoSink->retained_frame_ready = FALSE; |
478 | int destination_rowbytes = mWidth * mDepth; | 481 | int destination_rowbytes = mWidth * mDepth; |
479 | for (int row=0; row<mNaturalHeight; ++row) | 482 | for (int row=0; row<mCurrentHeight; ++row) |
480 | { | 483 | { |
481 | memcpy(&mPixels | 484 | memcpy(&mPixels |
482 | [destination_rowbytes * row], | 485 | [destination_rowbytes * row], |
483 | &mVideoSink->retained_frame_data | 486 | &mVideoSink->retained_frame_data |
484 | [mNaturalRowbytes * row], | 487 | [mCurrentRowbytes * row], |
485 | mNaturalRowbytes); | 488 | mCurrentRowbytes); |
486 | } | 489 | } |
487 | 490 | ||
488 | GST_OBJECT_UNLOCK(mVideoSink); | 491 | GST_OBJECT_UNLOCK(mVideoSink); |
489 | DEBUGMSG("NEW FRAME REALLY TRULY CONSUMED, TELLING HOST"); | 492 | DEBUGMSG("NEW FRAME REALLY TRULY CONSUMED, TELLING HOST"); |
490 | 493 | ||
491 | setDirty(0,0,mNaturalWidth,mNaturalHeight); | 494 | setDirty(0,0,mCurrentWidth,mCurrentHeight); |
492 | } | 495 | } |
493 | else | 496 | else |
494 | { | 497 | { |
@@ -835,27 +838,35 @@ MediaPluginGStreamer010::startup() | |||
835 | } | 838 | } |
836 | 839 | ||
837 | 840 | ||
838 | bool | 841 | void |
839 | MediaPluginGStreamer010::sizeChanged() | 842 | MediaPluginGStreamer010::sizeChanged() |
840 | { | 843 | { |
841 | // the shared writing space has possibly changed size/location/whatever | 844 | // the shared writing space has possibly changed size/location/whatever |
842 | 845 | ||
843 | // Check to see whether the movie's natural size has updated | 846 | // Check to see whether the movie's NATURAL size has been set yet |
844 | if (mNaturalWidth != mPreviousNaturalWidth || | 847 | if (1 == mNaturalWidth && |
845 | mNaturalHeight != mPreviousNaturalHeight) | 848 | 1 == mNaturalHeight) |
846 | { | 849 | { |
847 | mPreviousNaturalWidth = mNaturalWidth; | 850 | mNaturalWidth = mCurrentWidth; |
848 | mPreviousNaturalHeight = mNaturalHeight; | 851 | mNaturalHeight = mCurrentHeight; |
852 | DEBUGMSG("Media NATURAL size better detected as %dx%d", | ||
853 | mNaturalWidth, mNaturalHeight); | ||
854 | } | ||
855 | |||
856 | // if the size has changed then the shm has changed and the app needs telling | ||
857 | if (mCurrentWidth != mPreviousWidth || | ||
858 | mCurrentHeight != mPreviousHeight) | ||
859 | { | ||
860 | mPreviousWidth = mCurrentWidth; | ||
861 | mPreviousHeight = mCurrentHeight; | ||
849 | 862 | ||
850 | LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "size_change_request"); | 863 | LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "size_change_request"); |
851 | message.setValue("name", mTextureSegmentName); | 864 | message.setValue("name", mTextureSegmentName); |
852 | message.setValueS32("width", mNaturalWidth); | 865 | message.setValueS32("width", mNaturalWidth); |
853 | message.setValueS32("height", mNaturalHeight); | 866 | message.setValueS32("height", mNaturalHeight); |
854 | DEBUGMSG("<--- Sending size change request to application with name: '%s' - size is %d x %d", mTextureSegmentName.c_str(), mNaturalWidth, mNaturalHeight); | 867 | DEBUGMSG("<--- Sending size change request to application with name: '%s' - natural size is %d x %d", mTextureSegmentName.c_str(), mNaturalWidth, mNaturalHeight); |
855 | sendMessage(message); | 868 | sendMessage(message); |
856 | } | 869 | } |
857 | |||
858 | return true; | ||
859 | } | 870 | } |
860 | 871 | ||
861 | 872 | ||
@@ -940,10 +951,12 @@ void MediaPluginGStreamer010::receiveMessage(const char *message_string) | |||
940 | // lame to have to decide this now, it depends on the movie. Oh well. | 951 | // lame to have to decide this now, it depends on the movie. Oh well. |
941 | mDepth = 4; | 952 | mDepth = 4; |
942 | 953 | ||
954 | mCurrentWidth = 1; | ||
955 | mCurrentHeight = 1; | ||
956 | mPreviousWidth = 1; | ||
957 | mPreviousHeight = 1; | ||
943 | mNaturalWidth = 1; | 958 | mNaturalWidth = 1; |
944 | mNaturalHeight = 1; | 959 | mNaturalHeight = 1; |
945 | mPreviousNaturalWidth = 1; | ||
946 | mPreviousNaturalHeight = 1; | ||
947 | mWidth = 1; | 960 | mWidth = 1; |
948 | mHeight = 1; | 961 | mHeight = 1; |
949 | mTextureWidth = 1; | 962 | mTextureWidth = 1; |
@@ -984,7 +997,6 @@ void MediaPluginGStreamer010::receiveMessage(const char *message_string) | |||
984 | INFOMSG("MediaPluginGStreamer010::receiveMessage: shared memory added, name: %s, size: %d, address: %p", name.c_str(), int(info.mSize), info.mAddress); | 997 | INFOMSG("MediaPluginGStreamer010::receiveMessage: shared memory added, name: %s, size: %d, address: %p", name.c_str(), int(info.mSize), info.mAddress); |
985 | 998 | ||
986 | mSharedSegments.insert(SharedSegmentMap::value_type(name, info)); | 999 | mSharedSegments.insert(SharedSegmentMap::value_type(name, info)); |
987 | |||
988 | } | 1000 | } |
989 | else if(message_name == "shm_remove") | 1001 | else if(message_name == "shm_remove") |
990 | { | 1002 | { |
@@ -1063,7 +1075,7 @@ void MediaPluginGStreamer010::receiveMessage(const char *message_string) | |||
1063 | INFOMSG("**** = REAL RESIZE REQUEST FROM APP"); | 1075 | INFOMSG("**** = REAL RESIZE REQUEST FROM APP"); |
1064 | 1076 | ||
1065 | GST_OBJECT_LOCK(mVideoSink); | 1077 | GST_OBJECT_LOCK(mVideoSink); |
1066 | mVideoSink->resize_forced = true; | 1078 | mVideoSink->resize_forced_always = true; |
1067 | mVideoSink->resize_try_width = texture_width; | 1079 | mVideoSink->resize_try_width = texture_width; |
1068 | mVideoSink->resize_try_height = texture_height; | 1080 | mVideoSink->resize_try_height = texture_height; |
1069 | GST_OBJECT_UNLOCK(mVideoSink); | 1081 | GST_OBJECT_UNLOCK(mVideoSink); |