File indexing completed on 2024-04-21 04:53:50

0001 /*
0002     This file is part of the KMPlayer application
0003     SPDX-FileCopyrightText: 2003 Koos Vriezen <koos.vriezen@xs4all.nl>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #ifndef _KMPLAYER_BROADCAST_SOURCE_H_
0009 #define _KMPLAYER_BROADCAST_SOURCE_H_
0010 
0011 #include <list>
0012 #include <vector>
0013 
0014 #include <QFrame>
0015 #include <QPointer>
0016 
0017 #include "kmplayerappsource.h"
0018 #include "kmplayerconfig.h"
0019 
0020 class KMPlayerPrefBroadcastPage;        // broadcast
0021 class KMPlayerPrefBroadcastFormatPage;  // broadcast format
0022 class QListBox;
0023 class QComboBox;
0024 class QLineEdit;
0025 class QTable;
0026 class QPushButton;
0027 class KLed;
0028 class KProcess;
0029 
0030 namespace KMPlayer {
0031     class FFMpeg;
0032 }
0033 
0034 class FFServerSetting
0035 {
0036 public:
0037     FFServerSetting () {}
0038     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);
0039     FFServerSetting (const QStringList & sl) { *this = sl; }
0040     ~FFServerSetting () {}
0041     int index;
0042     QString name;
0043     QString format;
0044     QString audiocodec;
0045     QString audiobitrate;
0046     QString audiosamplerate;
0047     QString videocodec;
0048     QString videobitrate;
0049     QString quality;
0050     QString framerate;
0051     QString gopsize;
0052     QString width;
0053     QString height;
0054     QStringList acl;
0055     FFServerSetting & operator = (const QStringList &);
0056     FFServerSetting & operator = (const FFServerSetting & fs);
0057     const QStringList list ();
0058     QString & ffconfig (QString & buf);
0059 };
0060 
0061 typedef std::vector <FFServerSetting *> FFServerSettingList;
0062 
0063 
0064 class KMPlayerPrefBroadcastPage : public QFrame
0065 {
0066     Q_OBJECT
0067 public:
0068     KMPlayerPrefBroadcastPage (QWidget * parent);
0069     ~KMPlayerPrefBroadcastPage () {}
0070 
0071     QLineEdit * bindaddress;
0072     QLineEdit * port;
0073     QLineEdit * maxclients;
0074     QLineEdit * maxbandwidth;
0075     QLineEdit * feedfile;
0076     QLineEdit * feedfilesize;
0077 };
0078 
0079 class KMPlayerPrefBroadcastFormatPage : public QFrame
0080 {
0081     Q_OBJECT
0082 public:
0083     KMPlayerPrefBroadcastFormatPage (QWidget * parent, FFServerSettingList &);
0084     ~KMPlayerPrefBroadcastFormatPage () {}
0085 
0086     QListBox * profilelist;
0087     QComboBox * format;
0088     QLineEdit * audiocodec;
0089     QLineEdit * audiobitrate;
0090     QLineEdit * audiosamplerate;
0091     QLineEdit * videocodec;
0092     QLineEdit * videobitrate;
0093     QLineEdit * quality;
0094     QLineEdit * framerate;
0095     QLineEdit * gopsize;
0096     QLineEdit * moviewidth;
0097     QLineEdit * movieheight;
0098     QLineEdit * profile;
0099     QPushButton * startbutton;
0100     KLed * serverled;
0101     KLed * feedled;
0102     void setSettings (const FFServerSetting &);
0103     void getSettings (FFServerSetting &);
0104 private Q_SLOTS:
0105     void slotIndexChanged (int index);
0106     void slotItemHighlighted (int index);
0107     void slotTextChanged (const QString &);
0108     void slotLoad ();
0109     void slotSave ();
0110     void slotDelete ();
0111 private:
0112     QTable * accesslist;
0113     QPushButton * load;
0114     QPushButton * save;
0115     QPushButton * del;
0116     FFServerSettingList & profiles;
0117 };
0118 
0119 
0120 /*
0121  * Preference page for ffmpeg commandline arguments
0122  */
0123 class KMPlayerFFServerConfig : public KMPlayer::PreferencesPage
0124 {
0125 public:
0126     KMPlayerFFServerConfig ();
0127     ~KMPlayerFFServerConfig () {}
0128     virtual void write (KConfig *);
0129     virtual void read (KConfig *);
0130     virtual void sync (bool fromUI);
0131     virtual void prefLocation (QString & item, QString & icon, QString & tab);
0132     virtual QFrame * prefPage (QWidget * parent);
0133     int ffserverport;
0134     int maxclients;
0135     int maxbandwidth;
0136     QString feedfile;
0137     int feedfilesize;
0138     QString bindaddress;
0139 private:
0140     QPointer <KMPlayerPrefBroadcastPage> m_configpage;
0141 };
0142 
0143 /*
0144  * Preference page for ffserver
0145  */
0146 class KMPlayerBroadcastConfig : public QObject, public KMPlayer::PreferencesPage
0147 {
0148     Q_OBJECT
0149 public:
0150     KMPlayerBroadcastConfig (KMPlayer::PartBase * player, KMPlayerFFServerConfig * fsc);
0151     ~KMPlayerBroadcastConfig ();
0152 
0153     virtual void write (KConfig *);
0154     virtual void read (KConfig *);
0155     virtual void sync (bool fromUI);
0156     virtual void prefLocation (QString & item, QString & icon, QString & tab);
0157     virtual QFrame * prefPage (QWidget * parent);
0158 
0159     bool broadcasting () const;
0160     void stopServer ();
0161     const QString & serverURL () const { return m_ffserver_url; }
0162 
0163     FFServerSetting ffserversettings;
0164     FFServerSettingList ffserversettingprofiles;
0165 Q_SIGNALS:
0166     void broadcastStarted ();
0167     void broadcastStopped ();
0168 private Q_SLOTS:
0169     void processOutput (KProcess *, char *, int);
0170     void processStopped (KProcess * process);
0171     void startServer ();
0172     void startFeed ();
0173     void sourceChanged (KMPlayer::Source *, KMPlayer::Source *);
0174 private:
0175     KMPlayer::PartBase * m_player;
0176     KMPlayerFFServerConfig * m_ffserverconfig;
0177     QPointer <KMPlayerPrefBroadcastFormatPage> m_configpage;
0178     KMPlayer::FFMpeg * m_ffmpeg_process;
0179     KProcess * m_ffserver_process;
0180     bool m_endserver;
0181     QString m_ffserver_out;
0182     QString m_ffserver_url;
0183 };
0184 
0185 
0186 #endif //_KMPLAYER_BROADCAST_SOURCE_H_