r885: Don't delete a borrowed frame.
[cinelerra_cv/ct.git] / cinelerra / channel.C
blobc5ac0f8dd5318c6d44557b38b3907ea5f433ec26
1 #include "channel.h"
2 #include "bchash.h"
3 #include "filexml.h"
4 #include <string.h>
6 // Channel table entry for the TV tuner
8 Channel::Channel()
10         reset();
13 Channel::Channel(Channel *channel)
15         reset();
16         printf("Channel::Channel(Channel *channel) not supported\n");
19 Channel::~Channel()
24 void Channel::reset()
26 // GUI options
27         use_frequency = 0;
28         use_fine = 0;
29         use_norm = 0;
30         use_input = 0;
32         title[0] = 0;
33         device_name[0] = 0;
34         entry = 0;
35         freqtable = 0;
36         fine_tune = 0;
37         input = 0;
38         norm = 0;
39         device_index = 0;
40         tuner = 0;
41         has_scanning = 0;
43         audio_pid = 0x14;
44         video_pid = 0x11;
47 void Channel::dump()
49         printf("Channel::dump title=%s\n"
50                 "use_freq=%d\n"
51                 "use_fine=%d\n"
52                 "use_norm=%d\n"
53                 "use_input=%d\n"
54                 "has_scanning=%d\n",
55                 title,
56                 use_frequency,
57                 use_fine,
58                 use_norm,
59                 use_input,
60                 has_scanning);
63 Channel& Channel::operator=(Channel &channel)
65         printf("Channel::operator= is not supported.\n");
66         return *this;
69 void Channel::copy_settings(Channel *channel)
71         strcpy(this->title, channel->title);
72         this->entry = channel->entry;
73         this->freqtable = channel->freqtable;
74         this->fine_tune = channel->fine_tune;
75         this->input = channel->input;
76         this->norm = channel->norm;
77         this->device_index = channel->device_index;
78         this->tuner = channel->tuner;
79         this->audio_pid = channel->audio_pid;
80         this->video_pid = channel->video_pid;
83 void Channel::copy_usage(Channel *channel)
85         this->use_frequency = channel->use_frequency;
86         this->use_fine = channel->use_fine;
87         this->use_norm = channel->use_norm;
88         this->use_input = channel->use_input;
89         this->has_scanning = channel->has_scanning;
92 int Channel::load(FileXML *file)
94         int done = 0;
95         char *text;
98         while(!done)
99         {
100                 done = file->read_tag();
101                 if(!done)
102                 {
103                         if(file->tag.title_is("CHANNEL"))
104                         {
105                                 entry = file->tag.get_property("ENTRY", entry);
106                                 freqtable = file->tag.get_property("FREQTABLE", freqtable);
107                                 fine_tune = file->tag.get_property("FINE_TUNE", fine_tune);
108                                 input = file->tag.get_property("INPUT", input);
109                                 norm = file->tag.get_property("NORM", norm);
110                                 device_index = file->tag.get_property("DEVICE_INDEX", device_index);
111                                 tuner = file->tag.get_property("TUNER", tuner);
112                                 audio_pid = file->tag.get_property("AUDIO_PID", audio_pid);
113                                 video_pid = file->tag.get_property("VIDEO_PID", video_pid);
114                                 text = file->read_text();
115                                 strcpy(title, text);
116                         }
117                         else
118                         if(file->tag.title_is("/CHANNEL"))
119                                 return 0;
120                 }
121         }
122         return done;
125 int Channel::save(FileXML *file)
127         file->tag.set_title("CHANNEL");
128         file->tag.set_property("ENTRY", entry);
129         file->tag.set_property("FREQTABLE", freqtable);
130         file->tag.set_property("FINE_TUNE", fine_tune);
131         file->tag.set_property("INPUT", input);
132         file->tag.set_property("NORM", norm);
133         file->tag.set_property("DEVICE_INDEX", device_index);
134         file->tag.set_property("TUNER", tuner);
135         file->tag.set_property("AUDIO_PID", audio_pid);
136         file->tag.set_property("VIDEO_PID", video_pid);
137         file->append_tag();
138         file->append_text(title);
139         file->tag.set_title("/CHANNEL");
140         file->append_tag();
141         file->append_newline();
146 void Channel::load_defaults(BC_Hash *defaults)
148         freqtable = defaults->get("SCAN_FREQTABLE", freqtable);
149         input = defaults->get("SCAN_INPUT", input);
150         norm = defaults->get("SCAN_NORM", norm);
153 void Channel::save_defaults(BC_Hash *defaults)
155         defaults->update("SCAN_FREQTABLE", freqtable);
156         defaults->update("SCAN_INPUT", input);
157         defaults->update("SCAN_NORM", norm);