File indexing completed on 2024-04-21 15:38:15
0001 /* this file is part of the kmplayer application 0002 copyright (c) 2003 koos vriezen <koos.vriezen@xs4all.nl> 0003 0004 this program is free software; you can redistribute it and/or 0005 modify it under the terms of the gnu general public 0006 license as published by the free software foundation; either 0007 version 2 of the license, or (at your option) any later version. 0008 0009 this program is distributed in the hope that it will be useful, 0010 but without any warranty; without even the implied warranty of 0011 merchantability or fitness for a particular purpose. see the gnu 0012 general public license for more details. 0013 0014 you should have received a copy of the gnu general public license 0015 along with this program; see the file copying. if not, write to 0016 the free software foundation, inc., 59 temple place - suite 330, 0017 boston, ma 02111-1307, usa. 0018 */ 0019 0020 #ifndef _KMPLAYER_BROADCAST_SOURCE_H_ 0021 #define _KMPLAYER_BROADCAST_SOURCE_H_ 0022 0023 #include <list> 0024 #include <vector> 0025 0026 #include <qframe.h> 0027 #include <QPointer> 0028 0029 #include "kmplayerappsource.h" 0030 #include "kmplayerconfig.h" 0031 0032 class KMPlayerPrefBroadcastPage; // broadcast 0033 class KMPlayerPrefBroadcastFormatPage; // broadcast format 0034 class QListBox; 0035 class QComboBox; 0036 class QLineEdit; 0037 class QTable; 0038 class QPushButton; 0039 class KLed; 0040 class KProcess; 0041 0042 namespace KMPlayer { 0043 class FFMpeg; 0044 } 0045 0046 class KMPLAYER_NO_EXPORT FFServerSetting { 0047 public: 0048 KDE_NO_CDTOR_EXPORT FFServerSetting () {} 0049 FFServerSetting (int i, const QString & n, const QString & f, const QString & ac, int abr, int asr, const QString & vc, int vbr, int q, int fr, int gs, int w, int h); 0050 KDE_NO_CDTOR_EXPORT FFServerSetting (const QStringList & sl) { *this = sl; } 0051 KDE_NO_CDTOR_EXPORT ~FFServerSetting () {} 0052 int index; 0053 QString name; 0054 QString format; 0055 QString audiocodec; 0056 QString audiobitrate; 0057 QString audiosamplerate; 0058 QString videocodec; 0059 QString videobitrate; 0060 QString quality; 0061 QString framerate; 0062 QString gopsize; 0063 QString width; 0064 QString height; 0065 QStringList acl; 0066 FFServerSetting & operator = (const QStringList &); 0067 FFServerSetting & operator = (const FFServerSetting & fs); 0068 const QStringList list (); 0069 QString & ffconfig (QString & buf); 0070 }; 0071 0072 typedef std::vector <FFServerSetting *> FFServerSettingList; 0073 0074 0075 class KMPLAYER_NO_EXPORT KMPlayerPrefBroadcastPage : public QFrame { 0076 Q_OBJECT 0077 public: 0078 KMPlayerPrefBroadcastPage (QWidget * parent); 0079 KDE_NO_CDTOR_EXPORT ~KMPlayerPrefBroadcastPage () {} 0080 0081 QLineEdit * bindaddress; 0082 QLineEdit * port; 0083 QLineEdit * maxclients; 0084 QLineEdit * maxbandwidth; 0085 QLineEdit * feedfile; 0086 QLineEdit * feedfilesize; 0087 }; 0088 0089 class KMPLAYER_NO_EXPORT KMPlayerPrefBroadcastFormatPage : public QFrame { 0090 Q_OBJECT 0091 public: 0092 KMPlayerPrefBroadcastFormatPage (QWidget * parent, FFServerSettingList &); 0093 KDE_NO_CDTOR_EXPORT ~KMPlayerPrefBroadcastFormatPage () {} 0094 0095 QListBox * profilelist; 0096 QComboBox * format; 0097 QLineEdit * audiocodec; 0098 QLineEdit * audiobitrate; 0099 QLineEdit * audiosamplerate; 0100 QLineEdit * videocodec; 0101 QLineEdit * videobitrate; 0102 QLineEdit * quality; 0103 QLineEdit * framerate; 0104 QLineEdit * gopsize; 0105 QLineEdit * moviewidth; 0106 QLineEdit * movieheight; 0107 QLineEdit * profile; 0108 QPushButton * startbutton; 0109 KLed * serverled; 0110 KLed * feedled; 0111 void setSettings (const FFServerSetting &); 0112 void getSettings (FFServerSetting &); 0113 private slots: 0114 void slotIndexChanged (int index); 0115 void slotItemHighlighted (int index); 0116 void slotTextChanged (const QString &); 0117 void slotLoad (); 0118 void slotSave (); 0119 void slotDelete (); 0120 private: 0121 QTable * accesslist; 0122 QPushButton * load; 0123 QPushButton * save; 0124 QPushButton * del; 0125 FFServerSettingList & profiles; 0126 }; 0127 0128 0129 /* 0130 * Preference page for ffmpeg commandline arguments 0131 */ 0132 class KMPLAYER_NO_EXPORT KMPlayerFFServerConfig : public KMPlayer::PreferencesPage { 0133 public: 0134 KMPlayerFFServerConfig (); 0135 KDE_NO_CDTOR_EXPORT ~KMPlayerFFServerConfig () {} 0136 virtual void write (KConfig *); 0137 virtual void read (KConfig *); 0138 virtual void sync (bool fromUI); 0139 virtual void prefLocation (QString & item, QString & icon, QString & tab); 0140 virtual QFrame * prefPage (QWidget * parent); 0141 int ffserverport; 0142 int maxclients; 0143 int maxbandwidth; 0144 QString feedfile; 0145 int feedfilesize; 0146 QString bindaddress; 0147 private: 0148 QPointer <KMPlayerPrefBroadcastPage> m_configpage; 0149 }; 0150 0151 /* 0152 * Preference page for ffserver 0153 */ 0154 class KMPLAYER_NO_EXPORT KMPlayerBroadcastConfig : public QObject, public KMPlayer::PreferencesPage { 0155 Q_OBJECT 0156 public: 0157 KMPlayerBroadcastConfig (KMPlayer::PartBase * player, KMPlayerFFServerConfig * fsc); 0158 KDE_NO_CDTOR_EXPORT ~KMPlayerBroadcastConfig (); 0159 0160 virtual void write (KConfig *); 0161 virtual void read (KConfig *); 0162 virtual void sync (bool fromUI); 0163 virtual void prefLocation (QString & item, QString & icon, QString & tab); 0164 virtual QFrame * prefPage (QWidget * parent); 0165 0166 bool broadcasting () const; 0167 void stopServer (); 0168 KDE_NO_EXPORT const QString & serverURL () const { return m_ffserver_url; } 0169 0170 FFServerSetting ffserversettings; 0171 FFServerSettingList ffserversettingprofiles; 0172 signals: 0173 void broadcastStarted (); 0174 void broadcastStopped (); 0175 private slots: 0176 void processOutput (KProcess *, char *, int); 0177 void processStopped (KProcess * process); 0178 void startServer (); 0179 void startFeed (); 0180 void sourceChanged (KMPlayer::Source *, KMPlayer::Source *); 0181 private: 0182 KMPlayer::PartBase * m_player; 0183 KMPlayerFFServerConfig * m_ffserverconfig; 0184 QPointer <KMPlayerPrefBroadcastFormatPage> m_configpage; 0185 KMPlayer::FFMpeg * m_ffmpeg_process; 0186 KProcess * m_ffserver_process; 0187 bool m_endserver; 0188 QString m_ffserver_out; 0189 QString m_ffserver_url; 0190 }; 0191 0192 0193 #endif //_KMPLAYER_BROADCAST_SOURCE_H_