[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r10263: Implement more Video propert
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r10263: Implement more Video properties. |
Date: |
Wed, 12 Nov 2008 11:33:22 +0100 |
User-agent: |
Bazaar (1.5) |
------------------------------------------------------------
revno: 10263
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Wed 2008-11-12 11:33:22 +0100
message:
Implement more Video properties.
modified:
libcore/Video.cpp
libcore/Video.h
libcore/asobj/NetStream_as.cpp
libcore/asobj/NetStream_as.h
libcore/movie_instance.h
libmedia/FLVParser.cpp
libmedia/VideoDecoder.h
libmedia/ffmpeg/VideoDecoderFfmpeg.cpp
libmedia/ffmpeg/VideoDecoderFfmpeg.h
libmedia/gst/VideoDecoderGst.cpp
libmedia/gst/VideoDecoderGst.h
testsuite/misc-ming.all/NetStream-SquareTest.c
------------------------------------------------------------
revno: 10259.1.1
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Wed 2008-11-12 07:45:48 +0100
message:
Video width and height.
modified:
libcore/Video.cpp
libcore/Video.h
libcore/asobj/NetStream_as.cpp
libcore/asobj/NetStream_as.h
------------------------------------------------------------
revno: 10259.1.2
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Wed 2008-11-12 10:23:42 +0100
message:
Add a VideoDecoder::width() and VideoDecoder::height() as pure virtual
functions. Implement in Ffmpeg (working) and Gst (not yet tested).
Test that Video.width and Video.height are 0 until decoding starts.
Implement Video.width and Video.height.
Limit lines to 80 characters.
modified:
libbase/curl_adapter.cpp
libcore/Video.cpp
libcore/Video.h
libcore/asobj/NetStream_as.cpp
libcore/asobj/NetStream_as.h
libcore/movie_instance.h
libmedia/FLVParser.cpp
libmedia/VideoDecoder.h
libmedia/ffmpeg/VideoDecoderFfmpeg.cpp
libmedia/ffmpeg/VideoDecoderFfmpeg.h
libmedia/gst/VideoDecoderGst.cpp
libmedia/gst/VideoDecoderGst.h
testsuite/misc-ming.all/NetStream-SquareTest.c
------------------------------------------------------------
revno: 10259.1.3
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Wed 2008-11-12 10:40:48 +0100
message:
Initialize _width and _height.
modified:
libmedia/gst/VideoDecoderGst.cpp
------------------------------------------------------------
revno: 10259.1.4
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Wed 2008-11-12 10:47:02 +0100
message:
Drop ogg width test, as gstreamer doesn't know the dimensions.
modified:
testsuite/misc-ming.all/NetStream-SquareTest.c
=== modified file 'libcore/Video.cpp'
--- a/libcore/Video.cpp 2008-11-11 12:51:35 +0000
+++ b/libcore/Video.cpp 2008-11-12 09:23:42 +0000
@@ -106,6 +106,20 @@
}
}
+int
+Video::width() const
+{
+ if (_ns) return _ns->videoWidth();
+ return 0;
+}
+
+int
+Video::height() const
+{
+ if (_ns) return _ns->videoHeight();
+ return 0;
+}
+
void
Video::clear()
{
@@ -448,20 +462,14 @@
video_width(const fn_call& fn)
{
boost::intrusive_ptr<Video> video = ensureType<Video>(fn.this_ptr);
- UNUSED(video);
-
- log_unimpl("Video.width");
- return as_value();
+ return as_value(video->width());
}
as_value
video_height(const fn_call& fn)
{
boost::intrusive_ptr<Video> video = ensureType<Video>(fn.this_ptr);
- UNUSED(video);
-
- log_unimpl("Video.height");
- return as_value();
+ return as_value(video->height());
}
as_value
=== modified file 'libcore/Video.h'
--- a/libcore/Video.h 2008-11-11 08:43:14 +0000
+++ b/libcore/Video.h 2008-11-12 09:23:42 +0000
@@ -83,6 +83,22 @@
void clear();
+ /// Get the height of the video.
+ //
+ /// The method depends on whether it is an embedded or a live
+ /// stream. This returns 0 until the height is known, which for
+ /// FLV streams is only after decoding. The value may possibly
+ /// vary during playback.
+ int height() const;
+
+ /// Get the width of the video.
+ //
+ /// The method depends on whether it is an embedded or a live
+ /// stream. This returns 0 until the height is known, which for
+ /// FLV streams is only after decoding. The value may possibly
+ /// vary during playback.
+ int width() const;
+
protected:
#ifdef GNASH_USE_GC
=== modified file 'libcore/asobj/NetStream_as.cpp'
--- a/libcore/asobj/NetStream_as.cpp 2008-11-11 08:43:14 +0000
+++ b/libcore/asobj/NetStream_as.cpp 2008-11-12 09:23:42 +0000
@@ -774,7 +774,7 @@
void
NetStream_as::startAdvanceTimer()
{
- boost::intrusive_ptr<builtin_function> advanceCallback = \
+ boost::intrusive_ptr<builtin_function> advanceCallback =
new builtin_function(&NetStream_as::advanceWrapper);
std::auto_ptr<Timer> timer(new Timer);
unsigned long delayMS = 50; // TODO: base on media file FPS !!!
@@ -1726,6 +1726,19 @@
}
+int
+NetStream_as::videoHeight() const
+{
+ if (!_videoDecoder.get()) return 0;
+ return _videoDecoder->height();
+}
+
+int
+NetStream_as::videoWidth() const
+{
+ if (!_videoDecoder.get()) return 0;
+ return _videoDecoder->width();
+}
void
NetStream_as::advance()
=== modified file 'libcore/asobj/NetStream_as.h'
--- a/libcore/asobj/NetStream_as.h 2008-11-11 08:43:14 +0000
+++ b/libcore/asobj/NetStream_as.h 2008-11-12 09:23:42 +0000
@@ -345,6 +345,20 @@
return _playHead.getState();
}
+ /// Get the real height of the video in pixels if the decoder exists.
+ //
+ /// @return the height of the video in pixels or 0 if no decoder exists.
+ /// The width returned from the decoder may also vary, and will
+ /// be 0 until it knows the width.
+ int videoHeight() const;
+
+ /// Get the real width of the video in pixels if the decoder exists.
+ //
+ /// @return the width of the video in pixels or 0 if no decoder exists.
+ /// The width returned from the decoder may also vary, and will
+ /// be 0 until it knows the width.
+ int videoWidth() const;
+
/// Closes the video session and frees all ressources used for decoding
/// except the FLV-parser (this might not be correct).
void close();
=== modified file 'libcore/movie_instance.h'
--- a/libcore/movie_instance.h 2008-10-25 10:38:32 +0000
+++ b/libcore/movie_instance.h 2008-11-12 09:23:42 +0000
@@ -32,7 +32,6 @@
namespace gnash {
class movie_root;
class character;
- class movie_def_impl;
}
namespace gnash
=== modified file 'libmedia/FLVParser.cpp'
--- a/libmedia/FLVParser.cpp 2008-10-27 12:03:47 +0000
+++ b/libmedia/FLVParser.cpp 2008-11-12 09:23:42 +0000
@@ -256,7 +256,8 @@
case VIDEO_CODEC_H264:
{
boost::uint8_t packettype = _stream->read_byte();
- IF_VERBOSE_PARSE( log_debug(_("AVC packet type: %d"),
(unsigned)packettype) );
+ IF_VERBOSE_PARSE( log_debug(_("AVC packet type: %d"),
+ (unsigned)packettype) );
header = (packettype == 0);
@@ -271,7 +272,8 @@
break;
}
- std::auto_ptr<EncodedVideoFrame> frame = readVideoFrame(bodyLength-1,
flvtag.timestamp);
+ std::auto_ptr<EncodedVideoFrame> frame = readVideoFrame(bodyLength-1,
+ flvtag.timestamp);
if ( ! frame.get() ) {
log_error("could not read video frame?");
}
@@ -384,7 +386,8 @@
}
- std::auto_ptr<EncodedAudioFrame> frame = parseAudioTag(flvtag,
audiotag, thisTagPos);
+ std::auto_ptr<EncodedAudioFrame> frame =
+ parseAudioTag(flvtag, audiotag, thisTagPos);
if (!frame.get()) {
return false;
}
@@ -407,7 +410,8 @@
}
}
- std::auto_ptr<EncodedVideoFrame> frame = parseVideoTag(flvtag,
videotag, thisTagPos);
+ std::auto_ptr<EncodedVideoFrame> frame =
+ parseVideoTag(flvtag, videotag, thisTagPos);
if (!frame.get()) {
return false;
}
@@ -425,22 +429,29 @@
if ( chunk[11] != 2 )
{
// ::processTags relies on the first AMF0 value being a
string...
- log_unimpl(_("First byte of FLV_META_TAG is %d,
expected 0x02 (STRING AMF0 type)"),
- (int)chunk[11]);
+ log_unimpl(_("First byte of FLV_META_TAG is %d,
expected "
+ "0x02 (STRING AMF0 type)"),
+ static_cast<int>(chunk[11]));
}
// Extract information from the meta tag
- std::auto_ptr<SimpleBuffer> metaTag(new
SimpleBuffer(flvtag.body_size-1));
- size_t actuallyRead = _stream->read(metaTag->data(),
flvtag.body_size-1);
- if ( actuallyRead < flvtag.body_size-1 )
+ std::auto_ptr<SimpleBuffer> metaTag(new SimpleBuffer(
+ flvtag.body_size-1));
+ size_t actuallyRead = _stream->read(metaTag->data(),
+ flvtag.body_size - 1);
+
+ if ( actuallyRead < flvtag.body_size-1 )
{
- log_error("FLVParser::parseNextTag: can't read metaTag
(%d) body (needed %d bytes, only got %d)",
+ log_error("FLVParser::parseNextTag: can't read metaTag
(%d) "
+ "body (needed %d bytes, only got %d)",
FLV_META_TAG, flvtag.body_size, actuallyRead);
return false;
}
metaTag->resize(actuallyRead);
- boost::uint32_t terminus = getUInt24(metaTag->data() +
actuallyRead - 3);
- if (terminus != 9) {
+ boost::uint32_t terminus = getUInt24(metaTag->data() +
+ actuallyRead - 3);
+
+ if (terminus != 9) {
log_error(_("Corrupt FLV: Meta tag unterminated!"));
}
=== modified file 'libmedia/VideoDecoder.h'
--- a/libmedia/VideoDecoder.h 2008-10-27 16:05:13 +0000
+++ b/libmedia/VideoDecoder.h 2008-11-12 09:23:42 +0000
@@ -69,6 +69,19 @@
/// @return true if there is a frame ready to be popped.
///
virtual bool peek() = 0;
+
+ /// Get the width in pixels of the Video
+ //
+ /// @return The width of a video frame, or 0 until this is known.
+ /// This is used ultimately for the AS Video.width property.
+ virtual int width() const = 0;
+
+ /// Get the height in pixels of the Video
+ //
+ /// @return The height of a video frame, or 0 until this is known.
+ /// This is used ultimately for the AS Video.height property.
+ virtual int height() const = 0;
+
};
=== modified file 'libmedia/ffmpeg/VideoDecoderFfmpeg.cpp'
--- a/libmedia/ffmpeg/VideoDecoderFfmpeg.cpp 2008-10-27 16:05:13 +0000
+++ b/libmedia/ffmpeg/VideoDecoderFfmpeg.cpp 2008-11-12 09:23:42 +0000
@@ -130,17 +130,23 @@
boost::uint8_t* extradata=0;
int extradataSize=0;
- if ( info.extra.get() )
+ if (info.extra.get())
{
if (dynamic_cast<ExtraVideoInfoFfmpeg*>(info.extra.get())) {
- const ExtraVideoInfoFfmpeg& ei =
static_cast<ExtraVideoInfoFfmpeg&>(*info.extra);
+ const ExtraVideoInfoFfmpeg& ei =
+ static_cast<ExtraVideoInfoFfmpeg&>(*info.extra);
extradata = ei.data;
extradataSize = ei.dataSize;
- } else if (dynamic_cast<ExtraVideoInfoFlv*>(info.extra.get())) {
- const ExtraVideoInfoFlv& ei =
static_cast<ExtraVideoInfoFlv&>(*info.extra);
+ }
+ else if (dynamic_cast<ExtraVideoInfoFlv*>(info.extra.get())) {
+ const ExtraVideoInfoFlv& ei =
+ static_cast<ExtraVideoInfoFlv&>(*info.extra);
extradata = ei.data.get();
extradataSize = ei.size;
- } else assert(0);
+ }
+ else {
+ std::abort();
+ }
}
init(codec_id, info.width, info.height, extradata, extradataSize);
}
@@ -188,6 +194,20 @@
{
}
+int
+VideoDecoderFfmpeg::width() const
+{
+ if (!_videoCodecCtx.get()) return 0;
+ return _videoCodecCtx->getContext()->width;
+}
+
+int
+VideoDecoderFfmpeg::height() const
+{
+ if (!_videoCodecCtx.get()) return 0;
+ return _videoCodecCtx->getContext()->height;
+}
+
std::auto_ptr<GnashImage>
VideoDecoderFfmpeg::frameToImage(AVCodecContext* srcCtx,
const AVFrame& srcFrame)
=== modified file 'libmedia/ffmpeg/VideoDecoderFfmpeg.h'
--- a/libmedia/ffmpeg/VideoDecoderFfmpeg.h 2008-10-27 16:24:53 +0000
+++ b/libmedia/ffmpeg/VideoDecoderFfmpeg.h 2008-11-12 09:23:42 +0000
@@ -60,30 +60,36 @@
std::auto_ptr<GnashImage> pop();
bool peek();
-
-
+
+ int width() const;
+
+ int height() const;
+
+private:
+
+ /// Convert FLASH codec id to FFMPEG codec id
+ //
+ /// @return CODEC_ID_NONE for unsupported flash codecs
+ ///
+ static CodecID flashToFfmpegCodec(videoCodecType format);
+
/// \brief converts an video frame from (almost) any type to RGB24.
///
/// @param srcCtx The source context that was used to decode srcFrame.
/// @param srcFrame the source frame to be converted.
/// @return an AVPicture containing the converted image. Please be advised
- /// that the RGB data pointer is stored in
AVPicture::data[0]. The
- /// caller owns that pointer, which must be freed with
delete [].
- /// It is advised to wrap the pointer in a
boost::scoped_array.
- /// If conversion fails, AVPicture::data[0] will be NULL.
- std::auto_ptr<GnashImage> frameToImage(AVCodecContext* srcCtx, const
AVFrame& srcFrame);
-
- /// Convert FLASH codec id to FFMPEG codec id
- //
- /// @return CODEC_ID_NONE for unsupported flash codecs
- ///
- DSOEXPORT static enum CodecID flashToFfmpegCodec(videoCodecType format);
-
-private:
-
- void init(enum CodecID format, int width, int height, boost::uint8_t*
extradata=0, int extradataSize=0);
-
- std::auto_ptr<GnashImage> decode(const boost::uint8_t* input,
boost::uint32_t input_size);
+ /// that the RGB data pointer is stored in AVPicture::data[0]. The
+ /// caller owns that pointer, which must be freed with delete [].
+ /// It is advised to wrap the pointer in a boost::scoped_array.
+ /// If conversion fails, AVPicture::data[0] will be NULL.
+ std::auto_ptr<GnashImage> frameToImage(AVCodecContext* srcCtx,
+ const AVFrame& srcFrame);
+
+ void init(enum CodecID format, int width, int height,
+ boost::uint8_t* extradata=0, int extradataSize=0);
+
+ std::auto_ptr<GnashImage> decode(const boost::uint8_t* input,
+ boost::uint32_t input_size);
std::auto_ptr<GnashImage> decode(const EncodedVideoFrame* vf)
{
=== modified file 'libmedia/gst/VideoDecoderGst.cpp'
--- a/libmedia/gst/VideoDecoderGst.cpp 2008-10-27 16:05:13 +0000
+++ b/libmedia/gst/VideoDecoderGst.cpp 2008-11-12 09:40:48 +0000
@@ -32,6 +32,9 @@
// TODO: implement proper seeking.
VideoDecoderGst::VideoDecoderGst(GstCaps* caps)
+ :
+ _width(0),
+ _height(0)
{
// init GStreamer. TODO: what about doing this in MediaHandlerGst ctor?
gst_init (NULL, NULL);
@@ -39,6 +42,17 @@
setup(caps);
}
+int
+VideoDecoderGst::width() const
+{
+ return _width;
+}
+
+int
+VideoDecoderGst::height() const
+{
+ return _height;
+}
VideoDecoderGst::VideoDecoderGst(videoCodecType codec_type,
int /*width*/, int /*height*/,
@@ -169,14 +183,12 @@
GstStructure* structure = gst_caps_get_structure (caps, 0);
- gint height, width;
+ gst_structure_get_int (structure, "width", &_width);
+ gst_structure_get_int (structure, "height", &_height);
- gst_structure_get_int (structure, "width", &width);
- gst_structure_get_int (structure, "height", &height);
-
gst_caps_unref(caps);
- std::auto_ptr<GnashImage> ret(new gnashGstBuffer(buffer, width, height));
+ std::auto_ptr<GnashImage> ret(new gnashGstBuffer(buffer, _width, _height));
return ret;
}
=== modified file 'libmedia/gst/VideoDecoderGst.h'
--- a/libmedia/gst/VideoDecoderGst.h 2008-10-27 16:05:13 +0000
+++ b/libmedia/gst/VideoDecoderGst.h 2008-11-12 09:23:42 +0000
@@ -89,7 +89,21 @@
bool peek();
+ /// Get the width of the video
+ //
+ /// @return The width of the video in pixels or 0 if unknown.
+ int width() const;
+
+ /// Get the height of the video
+ //
+ /// @return The height of the video in pixels or 0 if unknown.
+ int height() const;
+
private:
+
+ int _width;
+ int _height;
+
void setup(GstCaps* caps);
VideoDecoderGst();
=== modified file 'testsuite/misc-ming.all/NetStream-SquareTest.c'
--- a/testsuite/misc-ming.all/NetStream-SquareTest.c 2008-11-11 13:26:59
+0000
+++ b/testsuite/misc-ming.all/NetStream-SquareTest.c 2008-11-12 09:47:02
+0000
@@ -52,7 +52,9 @@
char buffer_a[1028];
char buffer_b[2048];
- int video_width = 128;
+ // This is different from the real video width to make sure that
+ // Video.width returns the actual width (128).
+ int video_width = 130;
int video_height = 96;
if ( argc>1 ) mediadir=argv[1];
@@ -302,10 +304,19 @@
check(mo, "Video.prototype.hasOwnProperty('clear')");
check(mo, "Video.prototype.hasOwnProperty('height')");
check(mo, "Video.prototype.hasOwnProperty('width')");
-
+ check_equals(mo, "video.height", "0");
+ check_equals(mo, "video.width", "0");
+ check_equals(mo, "video2.height", "0");
+ check_equals(mo, "video2.width", "0");
+
add_actions(mo, "video.attachVideo(stream);");
add_actions(mo, "video2.attachVideo(stream2);");
+ check_equals(mo, "video.height", "0");
+ check_equals(mo, "video.width", "0");
+ check_equals(mo, "video2.height", "0");
+ check_equals(mo, "video2.width", "0");
+
// currentFps (read-only)
check_equals (mo, "typeof(stream.currentFps)", "'number'" );
add_actions(mo, "stream.currentFps = 'string';");
@@ -382,6 +393,11 @@
check_equals(mo, "video._yscale", "100");
check_equals(mo, "video._rotation", "0");
check_equals(mo, "video._target", "'/video'");
+ check_equals(mo, "video.height", "0");
+ check_equals(mo, "video.width", "0");
+ check_equals(mo, "video2.height", "0");
+ check_equals(mo, "video2.width", "0");
+
check(mo, "Video.prototype.hasOwnProperty('attachVideo')");
check(mo, "Video.prototype.hasOwnProperty('smoothing')");
check(mo, "Video.prototype.hasOwnProperty('deblocking')");
@@ -426,7 +442,8 @@
check_equals(mo, "typeof(video.getBounds)", "'undefined'");
SWFMovie_add(mo, (SWFBlock)newSWFAction(
-
+ "note('The video on the right is an OGG theora stream. It will appear "
+ "in Gnash, but not the Adobe player');"
"_root.onKeyDown = function() {"
" _root.note(' bufferLength:'+stream.bufferLength+"
" ' bytesLoaded:'+stream.bytesLoaded+"
@@ -639,10 +656,19 @@
SWFMovie_nextFrame(mo);
+ check_equals(mo, "video.height", "96");
+ check_equals(mo, "video.width", "128");
+
+ //add_actions(mo, "note('This is an OGG stream, so the Adobe player "
+ // "will fail the next two tests.');");
+ // gstreamer also fails, so let's not test this.
+ //check_equals(mo, "video2.height", "96");
+ //check_equals(mo, "video2.width", "128");
+
check_equals(mo, "metadataNotified", "1");
check_equals(mo, "stopNotified", "2");
check_equals(mo, "startNotified", "1");
- SWFMovie_add(mo, (SWFBlock)newSWFAction("totals(168); stop();
end_of_test=true;"));
+ SWFMovie_add(mo, (SWFBlock)newSWFAction("totals(182); stop();
end_of_test=true;"));
SWFMovie_nextFrame(mo);
- [Gnash-commit] /srv/bzr/gnash/trunk r10263: Implement more Video properties.,
Benjamin Wolsey <=