1 /* cclive
2  * Copyright (C) 2013  Toni Gundogdu <legatvs@gmail.com>
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef compat_media_h
19 #define compat_media_h
20 
21 namespace quvi {
22 
23 class media_base
24 {
25   virtual void _init(quvi_t, quvi_media_t) = 0;
26 protected:
~media_base()27   inline virtual ~media_base() { }
28 };
29 
30 class media_impl
31 {
32 protected:
33   std::string _content_type;
34   std::string _stream_url;
35   std::string _file_ext;
36   std::string _title;
37   std::string _id;
38   double _content_length;
39 protected:
media_impl(const media_impl & a)40   inline media_impl(const media_impl& a): _content_length(0)  { _copy(a); }
media_impl()41   inline media_impl(): _content_length(0)                     { }
~media_impl()42   inline virtual ~media_impl()                                { }
43   inline media_impl& operator=(const media_impl& a)
44   {
45     if (this != &a)
46       _copy(a);
47     return *this;
48   }
_copy(const media_impl & a)49   inline void _copy(const media_impl& a)
50   {
51     _content_type = a._content_type;
52     _stream_url = a._stream_url;
53     _file_ext = a._file_ext;
54     _title = a._title;
55     _id = a._id;
56 
57     _content_length = a._content_length;
58   }
59 public:
content_type()60   inline const std::string& content_type() const  { return _content_type; }
stream_url()61   inline const std::string& stream_url() const    { return _stream_url; }
file_ext()62   inline const std::string& file_ext() const      { return _file_ext; }
title()63   inline const std::string& title() const         { return _title; }
id()64   inline const std::string& id() const            { return _id; }
content_length()65   inline double content_length() const            { return _content_length; }
66 };
67 
68 class media_pt4 : public media_impl
69 {
70   void _init(quvi_t, quvi_media_t);
71 public:
media_pt4(const media_pt4 & a)72   inline media_pt4(const media_pt4& a): media_impl(a)       { }
media_pt4(quvi_t q,quvi_media_t qm)73   inline media_pt4(quvi_t q, quvi_media_t qm): media_impl() { _init(q, qm); }
media_pt4()74   inline media_pt4(): media_impl()                          { }
~media_pt4()75   inline virtual ~media_pt4() { }
76   inline media_pt4& operator=(const media_pt4& a)
77   {
78     if (this != &a)
79       _copy(a);
80     return *this;
81   }
82 };
83 
84 typedef class media_pt4 media;
85 
86 } // namespace quvi
87 
88 #endif // compat_media_h
89 
90 // vim: set ts=2 sw=2 tw=72 expandtab:
91