~ubuntu-branches/ubuntu/precise/gmlive/precise

« back to all changes in this revision

Viewing changes to src/gmplayer.h

  • Committer: Bazaar Package Importer
  • Author(s): Aron Xu
  • Date: 2010-01-28 10:02:52 UTC
  • Revision ID: james.westby@ubuntu.com-20100128100252-b0yb0n4zm7s85ce7
Tags: upstream-0.22.2
Import upstream version 0.22.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * =====================================================================================
 
3
 * 
 
4
 *       Filename:  gmplayer.h
 
5
 * 
 
6
 *    Description:  播放网络流 
 
7
 * 
 
8
 *        Version:  1.0
 
9
 *        Created:  2007年12月22日 20时40分35秒 CST
 
10
 *       Revision:  none
 
11
 *       Compiler:  gcc
 
12
 * 
 
13
 *         Author:  wind (xihe), xihels@gmail.com
 
14
 *        Company:  cyclone
 
15
 * 
 
16
 * =====================================================================================
 
17
 */
 
18
#ifndef GTKMPLAYER_H_
 
19
#define GTKMPLAYER_H_
 
20
 
 
21
#include <stdlib.h>
 
22
#include <iostream>
 
23
#include <gtkmm.h>
 
24
#include <gtkmm/socket.h>
 
25
 
 
26
class GMplayer : public Gtk::Socket {
 
27
        public:
 
28
                GMplayer();
 
29
                ~GMplayer();
 
30
                void send_ctrl_command(const char* c);
 
31
                void pause(); 
 
32
                void mute(bool);
 
33
                void stop();
 
34
                void restart() { stop(); start();}
 
35
                void start() 
 
36
                {
 
37
                        is_record ? start_record() : start_play();
 
38
                }
 
39
                void start(const std::string& filename)
 
40
                {
 
41
                        is_record ? start_record(filename) : start_play(filename);
 
42
                }
 
43
                
 
44
 
 
45
                void set_cache(int var) { icache = var; }
 
46
                void set_record(bool record)
 
47
                { 
 
48
                        if (is_record != record)
 
49
                                stop();
 
50
                        is_record = record; 
 
51
                }
 
52
                void set_outfilename(const std::string& filename, const std::string& name = "");
 
53
                bool running() const { return is_running; }
 
54
                bool pausing() const { return is_pause; }
 
55
                bool recording() const { return is_recording; }
 
56
                void set_out_slot(const sigc::slot<bool, Glib::IOCondition>& slot)
 
57
                { out_slot = slot; }
 
58
 
 
59
                ssize_t get_mplayer_log(char* buf, size_t count) 
 
60
                { return read(player_child_tem, buf, count); }
 
61
 
 
62
                typedef sigc::signal<void> type_signal_stop;
 
63
                type_signal_stop signal_stop()
 
64
                { return signal_stop_; }
 
65
 
 
66
                typedef sigc::signal<void> type_signal_start;
 
67
                type_signal_start signal_start()
 
68
                { return signal_start_; }       
 
69
        private:
 
70
                void    start_play(const std::string&);
 
71
                void    start_record(const std::string&);
 
72
                void    start_play();
 
73
                void    start_record();
 
74
                int     my_system(char* const argv[]);
 
75
                bool    on_delay_reboot();
 
76
                bool    on_delay_record_reboot();
 
77
                void    on_start_record();
 
78
                void    on_stop_record();
 
79
                bool    on_update_progress();
 
80
                void    on_preview();
 
81
                void    wait_mplayer_exit(GPid, int);
 
82
                void    wait_record_exit(GPid, int);
 
83
                void    set_s_pipe();
 
84
                void    set_m_pipe();
 
85
                void    create_pipe();
 
86
                void    close_pipe();
 
87
 
 
88
                sigc::slot<bool, Glib::IOCondition>     out_slot;
 
89
                sigc::connection                update_progress_conn;
 
90
                sigc::connection                ptm_conn;
 
91
                sigc::connection                wait_conn;
 
92
                sigc::connection                wait_record_conn;
 
93
                type_signal_stop                signal_stop_;
 
94
                type_signal_start               signal_start_;
 
95
 
 
96
                std::string playfilename;               /* filename (internal)*/
 
97
                std::string recordfilename;
 
98
                std::string channelname;
 
99
                std::string outfilename;
 
100
                std::string outfilenamebase;
 
101
                std::string outfilenameext;
 
102
                int             outfile_num;
 
103
                int             outfile;
 
104
                Gtk::Window*            record_window;
 
105
                Gtk::Label*             record_name;
 
106
                Gtk::ProgressBar*       progress_bar;
 
107
 
 
108
                int             icache;
 
109
                int                     player_child_tem;       // 主进程和子进程的连接管道的主进程则(播放)
 
110
                int             player_child_tem2;      // 子进程端的标准输入,输出 (播放)
 
111
 
 
112
                int                     player_pid;     /* play mplayer's pid (internal)*/
 
113
                int                     record_pid;     /* record mplayer's pid (internal)*/
 
114
                bool            is_running;     
 
115
                bool            is_recording;
 
116
                bool            is_record;
 
117
                bool            is_pause;       
 
118
};
 
119
 
 
120
#endif