]> git.sesse.net Git - casparcg/blob - core/frame.h
45d6bfdea19374942c6035fc630b60984d63adc5
[casparcg] / core / frame.h
1 #pragma once
2
3 #include <boost/noncopyable.hpp>
4 #include <boost/range.hpp>
5
6 #include <stdint.h>
7
8 #include "frame/pixel_format.h"
9 #include "video_format.h"
10
11 namespace caspar { namespace core {
12
13 struct data_frame : boost::noncopyable
14 {
15         virtual ~frame()
16         {
17         }
18
19         virtual const struct  pixel_format_desc& get_pixel_format_desc() const = 0;
20
21         virtual const boost::iterator_range<const uint8_t*> image_data() const = 0;
22         virtual const boost::iterator_range<const int32_t*> audio_data() const = 0;
23         
24         virtual const boost::iterator_range<uint8_t*> image_data() = 0;
25         virtual const boost::iterator_range<int32_t*> audio_data() = 0;
26
27         virtual double get_frame_rate() const = 0;
28         virtual field_mode get_field_mode() const = 0;
29
30         virtual int width() const = 0;
31         virtual int height() const = 0;
32
33         static safe_ptr<frame> empty()
34         {
35                 struct empty_frame : public frame
36                 {
37                         virtual const struct  video_format_desc& get_video_format_desc() const
38                         {
39                                 static video_format_desc invalid;
40                                 return invalid;
41                         }
42                         virtual const struct  pixel_format_desc& get_pixel_format_desc() const 
43                         {
44                                 static pixel_format_desc invalid;
45                                 return invalid;
46                         }
47                         virtual const boost::iterator_range<const uint8_t*> image_data() const 
48                         {
49                                 return boost::iterator_range<const uint8_t*>();
50                         }
51                         virtual const boost::iterator_range<const int32_t*> audio_data() const 
52                         {
53                                 return boost::iterator_range<const int32_t*>();
54                         }
55                         const boost::iterator_range<uint8_t*> image_data()
56                         {
57                                 return boost::iterator_range<uint8_t*>();
58                         }
59                         const boost::iterator_range<int32_t*> audio_data()
60                         {
61                                 return boost::iterator_range<int32_t*>();
62                         }
63                         virtual double get_frame_rate() const
64                         {
65                                 return 0.0;
66                         }
67                         virtual field_mode get_field_mode() const
68                         {
69                                 return field_mode::empty;
70                         }
71                         virtual int width() const
72                         {
73                                 return 0;
74                         }
75                         virtual int height() const
76                         {
77                                 return 0;
78                         }
79                 };
80
81                 static safe_ptr<empty_frame> empty;
82                 return empty;
83         }
84 };
85
86 }}