[vlc-commits] ActiveX: added MediaDescription

Sergey Radionov git at videolan.org
Mon Mar 26 19:08:44 CEST 2012


npapi-vlc | branch: master | Sergey Radionov <rsatom at gmail.com> | Mon Mar 26 19:34:09 2012 +0700| [e3d3b096d87e6f1a3cfc16ad1ad42869862c85a1] | committer: Jean-Baptiste Kempf

ActiveX: added MediaDescription

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/npapi-vlc.git/?a=commit;h=e3d3b096d87e6f1a3cfc16ad1ad42869862c85a1
---

 activex/axvlc.idl       |   48 +++++++++++++++++++++++
 activex/vlccontrol2.cpp |   98 ++++++++++++++++++++++++++++++++++++++++++++++-
 activex/vlccontrol2.h   |   33 ++++++++++++++++
 3 files changed, 178 insertions(+), 1 deletions(-)

diff --git a/activex/axvlc.idl b/activex/axvlc.idl
index 52222b0..63dba0b 100644
--- a/activex/axvlc.idl
+++ b/activex/axvlc.idl
@@ -571,6 +571,51 @@ library AXVLC
 
     [
       odl,
+      uuid(796A2C2D-5B11-4fb5-9077-56D5E674972B),
+      helpstring("VLC Media Description"),
+      dual,
+      oleautomation
+    ]
+    interface IVLCMediaDescription : IDispatch
+    {
+        [propget]
+        HRESULT title([out, retval] BSTR* val);
+        [propget]
+        HRESULT artist([out, retval] BSTR* val);
+        [propget]
+        HRESULT genre([out, retval] BSTR* val);
+        [propget]
+        HRESULT copyright([out, retval] BSTR* val);
+        [propget]
+        HRESULT album([out, retval] BSTR* val);
+        [propget]
+        HRESULT trackNumber([out, retval] BSTR* val);
+        [propget]
+        HRESULT description([out, retval] BSTR* val);
+        [propget]
+        HRESULT rating([out, retval] BSTR* val);
+        [propget]
+        HRESULT date([out, retval] BSTR* val);
+        [propget]
+        HRESULT setting([out, retval] BSTR* val);
+        [propget]
+        HRESULT URL([out, retval] BSTR* val);
+        [propget]
+        HRESULT language([out, retval] BSTR* val);
+        [propget]
+        HRESULT nowPlaying([out, retval] BSTR* val);
+        [propget]
+        HRESULT publisher([out, retval] BSTR* val);
+        [propget]
+        HRESULT encodedBy([out, retval] BSTR* val);
+        [propget]
+        HRESULT artworkURL([out, retval] BSTR* val);
+        [propget]
+        HRESULT trackID([out, retval] BSTR* val);
+    }
+
+    [
+      odl,
       uuid(2D719729-5333-406C-BF12-8DE787FD65E3),
       helpstring("VLC Control"),
       dual,
@@ -650,6 +695,9 @@ library AXVLC
         HRESULT FullscreenEnabled([out, retval] VARIANT_BOOL* enabled);
         [id(DISPID_FSEnabled), propput, helpstring("Returns/sets availability of fullscreen mode.")]
         HRESULT FullscreenEnabled([in] VARIANT_BOOL enabled);
+
+        [propget, helpstring("Returns the media description object.")]
+        HRESULT mediaDescription([out, retval] IVLCMediaDescription** obj);
     };
 
     [
diff --git a/activex/vlccontrol2.cpp b/activex/vlccontrol2.cpp
index 6dac96a..fb38a1c 100644
--- a/activex/vlccontrol2.cpp
+++ b/activex/vlccontrol2.cpp
@@ -64,6 +64,7 @@ BIND_INTERFACE( VLCPlaylistItems )
 BIND_INTERFACE( VLCPlaylist )
 BIND_INTERFACE( VLCVideo )
 BIND_INTERFACE( VLCSubtitle )
+BIND_INTERFACE( VLCMediaDescription )
 
 #undef  BIND_INTERFACE
 
@@ -1203,7 +1204,96 @@ STDMETHODIMP VLCLogo::put_position(BSTR val)
     CoTaskMemFree(n);
     return hr;
 }
+/****************************************************************************/
+
+STDMETHODIMP VLCMediaDescription::get_meta(BSTR* val, libvlc_meta_t e_meta)
+{
+    if( NULL == val )
+        return E_POINTER;
+
+    *val = 0;
+
+    libvlc_media_player_t *p_md;
+    HRESULT hr = getMD(&p_md);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_media_t * p_media = libvlc_media_player_get_media(p_md);
+        const char* info = p_media ? libvlc_media_get_meta(p_media, e_meta) : 0;
+        *val = info ? BSTRFromCStr(CP_UTF8, info) : 0;
+        hr = *val ? S_OK : E_FAIL;
+    }
+    return hr;
+}
+
+STDMETHODIMP VLCMediaDescription::get_title(BSTR *val)
+{
+    return get_meta(val, libvlc_meta_Title);
+}
 
+STDMETHODIMP VLCMediaDescription::get_artist(BSTR *val)
+{
+    return get_meta(val, libvlc_meta_Artist);
+}
+STDMETHODIMP VLCMediaDescription::get_genre(BSTR *val)
+{
+    return get_meta(val, libvlc_meta_Genre);
+}
+STDMETHODIMP VLCMediaDescription::get_copyright(BSTR *val)
+{
+    return get_meta(val, libvlc_meta_Copyright);
+}
+STDMETHODIMP VLCMediaDescription::get_album(BSTR *val)
+{
+    return get_meta(val, libvlc_meta_Album);
+}
+STDMETHODIMP VLCMediaDescription::get_trackNumber(BSTR *val)
+{
+    return get_meta(val, libvlc_meta_TrackNumber);
+}
+STDMETHODIMP VLCMediaDescription::get_description(BSTR *val)
+{
+    return get_meta(val, libvlc_meta_Description);
+}
+STDMETHODIMP VLCMediaDescription::get_rating(BSTR *val)
+{
+    return get_meta(val, libvlc_meta_Rating);
+}
+STDMETHODIMP VLCMediaDescription::get_date(BSTR *val)
+{
+    return get_meta(val, libvlc_meta_Date);
+}
+STDMETHODIMP VLCMediaDescription::get_setting(BSTR *val)
+{
+    return get_meta(val, libvlc_meta_Setting);
+}
+STDMETHODIMP VLCMediaDescription::get_URL(BSTR *val)
+{
+    return get_meta(val, libvlc_meta_URL);
+}
+STDMETHODIMP VLCMediaDescription::get_language(BSTR *val)
+{
+    return get_meta(val, libvlc_meta_Language);
+}
+STDMETHODIMP VLCMediaDescription::get_nowPlaying(BSTR *val)
+{
+    return get_meta(val, libvlc_meta_NowPlaying);
+}
+STDMETHODIMP VLCMediaDescription::get_publisher(BSTR *val)
+{
+    return get_meta(val, libvlc_meta_Publisher);
+}
+STDMETHODIMP VLCMediaDescription::get_encodedBy(BSTR *val)
+{
+    return get_meta(val, libvlc_meta_EncodedBy);
+}
+STDMETHODIMP VLCMediaDescription::get_artworkURL(BSTR *val)
+{
+    return get_meta(val, libvlc_meta_ArtworkURL);
+}
+STDMETHODIMP VLCMediaDescription::get_trackID(BSTR *val)
+{
+    return get_meta(val, libvlc_meta_TrackID);
+}
 /****************************************************************************/
 
 VLCControl2::VLCControl2(VLCPlugin *p_instance) :
@@ -1213,7 +1303,8 @@ VLCControl2::VLCControl2(VLCPlugin *p_instance) :
     _p_vlcinput(new VLCInput(p_instance)),
     _p_vlcplaylist(new VLCPlaylist(p_instance)),
     _p_vlcsubtitle(new VLCSubtitle(p_instance)),
-    _p_vlcvideo(new VLCVideo(p_instance))
+    _p_vlcvideo(new VLCVideo(p_instance)),
+    _p_vlcmedia_desc(p_instance)
 {
 }
 
@@ -1497,3 +1588,8 @@ STDMETHODIMP VLCControl2::get_video(IVLCVideo** obj)
 {
     return object_get(obj,_p_vlcvideo);
 }
+
+STDMETHODIMP VLCControl2::get_mediaDescription(IVLCMediaDescription** obj)
+{
+    return object_get<IVLCMediaDescription>(obj, &_p_vlcmedia_desc);
+}
diff --git a/activex/vlccontrol2.h b/activex/vlccontrol2.h
index 6303c2b..cf25258 100644
--- a/activex/vlccontrol2.h
+++ b/activex/vlccontrol2.h
@@ -329,6 +329,36 @@ private:
     IVLCDeinterlace *_p_vlcdeint;
 };
 
+class VLCMediaDescription:
+    public VLCInterface<VLCMediaDescription, IVLCMediaDescription>
+{
+public:
+    VLCMediaDescription(VLCPlugin *p)
+        : VLCInterface<VLCMediaDescription, IVLCMediaDescription>(p) { }
+
+    // IVLCMediaDescription methods
+    STDMETHODIMP get_title(BSTR*);
+    STDMETHODIMP get_artist(BSTR*);
+    STDMETHODIMP get_genre(BSTR*);
+    STDMETHODIMP get_copyright(BSTR*);
+    STDMETHODIMP get_album(BSTR*);
+    STDMETHODIMP get_trackNumber(BSTR*);
+    STDMETHODIMP get_description(BSTR*);
+    STDMETHODIMP get_rating(BSTR*);
+    STDMETHODIMP get_date(BSTR*);
+    STDMETHODIMP get_setting(BSTR*);
+    STDMETHODIMP get_URL(BSTR*);
+    STDMETHODIMP get_language(BSTR*);
+    STDMETHODIMP get_nowPlaying(BSTR*);
+    STDMETHODIMP get_publisher(BSTR*);
+    STDMETHODIMP get_encodedBy(BSTR*);
+    STDMETHODIMP get_artworkURL(BSTR*);
+    STDMETHODIMP get_trackID(BSTR*);
+
+private:
+    STDMETHODIMP get_meta(BSTR*, libvlc_meta_t);
+};
+
 class VLCControl2 : public IVLCControl2
 {
 public:
@@ -389,6 +419,7 @@ public:
     STDMETHODIMP get_playlist(IVLCPlaylist**);
     STDMETHODIMP get_subtitle(IVLCSubtitle**);
     STDMETHODIMP get_video(IVLCVideo**);
+    STDMETHODIMP get_mediaDescription(IVLCMediaDescription**);
 
 protected:
     HRESULT loadTypeInfo();
@@ -402,6 +433,8 @@ private:
     IVLCPlaylist *_p_vlcplaylist;
     IVLCSubtitle *_p_vlcsubtitle;
     IVLCVideo    *_p_vlcvideo;
+
+    VLCMediaDescription    _p_vlcmedia_desc;
 };
 
 #endif



More information about the vlc-commits mailing list