Skip to content

Commit

Permalink
Introduce media file tab for controlling playback
Browse files Browse the repository at this point in the history
  • Loading branch information
bear101 committed Sep 2, 2024
1 parent 9fab326 commit 33c4d2d
Show file tree
Hide file tree
Showing 7 changed files with 461 additions and 245 deletions.
5 changes: 3 additions & 2 deletions Client/qtTeamTalk/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ if (Qt5_FOUND OR Qt6_FOUND)
serverlogeventsmodel.h textmessagecontainer.h
useraccountsmodel.h encryptionsetupdlg.h utiltt.h utilxml.h
utilos.h serverdlg.h moveusersdlg.h useraccountdlg.h soundeventsmodel.h
mytableview.h mytabwidget.h shortcutsmodel.h
mytableview.h mytabwidget.h shortcutsmodel.h utilmedia.h

main.cpp mainwindow.cpp preferencesdlg.cpp uservideowidget.cpp
channelstree.cpp channeldlg.cpp userinfodlg.cpp
bannedusersdlg.cpp useraccountsdlg.cpp videogridwidget.cpp
Expand All @@ -110,7 +111,7 @@ if (Qt5_FOUND OR Qt6_FOUND)
serverlogeventsmodel.cpp textmessagecontainer.cpp
useraccountsmodel.cpp encryptionsetupdlg.cpp utiltt.cpp utilxml.cpp
utilos.cpp serverdlg.cpp moveusersdlg.cpp useraccountdlg.cpp soundeventsmodel.cpp
mytableview.cpp mytabwidget.cpp shortcutsmodel.cpp
mytableview.cpp mytabwidget.cpp shortcutsmodel.cpp utilmedia.cpp
mainwindow.ui channel.ui preferences.ui
serverlist.ui userinfo.ui bannedusers.ui useraccounts.ui
serverproperties.ui uservideo.ui keycomp.ui textmessage.ui
Expand Down
84 changes: 68 additions & 16 deletions Client/qtTeamTalk/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include "utilvideo.h"
#include "utiltts.h"
#include "utilxml.h"
#include "utilmedia.h"
#include "moveusersdlg.h"
#include "useraccountdlg.h"

Expand Down Expand Up @@ -223,29 +224,15 @@ MainWindow::MainWindow(const QString& cfgfile)
ui.actionExit->setShortcut(QKeySequence::Quit);
#endif

connect(ui.msgEdit, &QLineEdit::textChanged, this, &MainWindow::slotTextChanged);
connect(ui.sendButton, &QAbstractButton::clicked,
this, &MainWindow::slotSendChannelMessage);
connect(ui.msgEdit, &ChatLineEdit::sendTextMessage,
this, &MainWindow::slotSendChannelMessage);
connect(ui.videosendButton, &QAbstractButton::clicked,
this, &MainWindow::slotSendChannelMessage);
connect(ui.desktopsendButton, &QAbstractButton::clicked,
this, &MainWindow::slotSendChannelMessage);
connect(ui.videomsgEdit, &ChatLineEdit::sendTextMessage,
this, &MainWindow::slotSendChannelMessage);
connect(ui.videomsgEdit, &QLineEdit::textChanged, this, &MainWindow::slotTextChanged);
connect(ui.desktopmsgEdit, &QLineEdit::textChanged, this, &MainWindow::slotTextChanged);
connect(ui.desktopmsgEdit, &ChatLineEdit::sendTextMessage,
this, &MainWindow::slotSendChannelMessage);
/* Volume controls */
connect(ui.micSlider, &QAbstractSlider::valueChanged,
this, &MainWindow::slotMicrophoneGainChanged);
connect(ui.volumeSlider, &QAbstractSlider::valueChanged,
this, &MainWindow::slotMasterVolumeChanged);
connect(ui.voiceactSlider, &QAbstractSlider::valueChanged,
this, &MainWindow::slotVoiceActivationLevelChanged);

/* ui.channelsWidget */
/* Channels tree */
connect(ui.channelsWidget, &QTreeWidget::itemSelectionChanged,
this, &MainWindow::slotTreeSelectionChanged);
connect(ui.channelsWidget, &QWidget::customContextMenuRequested,
Expand All @@ -259,6 +246,7 @@ MainWindow::MainWindow(const QString& cfgfile)
connect(ui.channelsWidget,
&ChannelsTree::transmitusersChanged,
this, &MainWindow::slotTransmitUsersChanged);

/* Video-tab (video-grid) */
connect(this, &MainWindow::newVideoCaptureFrame, ui.videogridWidget,
&VideoGridWidget::slotNewVideoFrame);
Expand All @@ -272,6 +260,7 @@ MainWindow::MainWindow(const QString& cfgfile)
this, &MainWindow::slotUpdateVideoTabUI);
connect(ui.videogridWidget, &VideoGridWidget::userVideoSelected,
this, &MainWindow::slotUpdateVideoTabUI);

/* Desktop-tab (desktop-grid) */
connect(this, &MainWindow::newDesktopWindow, ui.desktopgridWidget,
&DesktopGridWidget::userDesktopWindowUpdate);
Expand All @@ -289,6 +278,18 @@ MainWindow::MainWindow(const QString& cfgfile)
this, &MainWindow::slotUpdateDesktopTabUI);
connect(ui.desktopgridWidget, &DesktopGridWidget::userDesktopSelected,
this, &MainWindow::slotUpdateDesktopTabUI);

/* Chat-tab */
connect(ui.msgEdit, &QLineEdit::textChanged, this, &MainWindow::slotTextChanged);
connect(ui.sendButton, &QAbstractButton::clicked,
this, &MainWindow::slotSendChannelMessage);
connect(ui.msgEdit, &ChatLineEdit::sendTextMessage,
this, &MainWindow::slotSendChannelMessage);

/* Media-tab */
connect(ui.playbackOffsetSlider, &QSlider::sliderMoved,
this, &MainWindow::changeMediaFileOffset);

/* Files-tab */
connect(ui.uploadButton, &QAbstractButton::clicked, this, &MainWindow::slotChannelsUploadFile);
connect(ui.downloadButton, &QAbstractButton::clicked, this, &MainWindow::slotChannelsDownloadFile);
Expand All @@ -303,7 +304,13 @@ MainWindow::MainWindow(const QString& cfgfile)
this, &MainWindow::slotUploadFiles);
connect(ui.filesView, &QWidget::customContextMenuRequested,
this, &MainWindow::slotFilesContextMenu);

/* Video-tab buttons */
connect(ui.videosendButton, &QAbstractButton::clicked,
this, &MainWindow::slotSendChannelMessage);
connect(ui.videomsgEdit, &QLineEdit::textChanged, this, &MainWindow::slotTextChanged);
connect(ui.videomsgEdit, &ChatLineEdit::sendTextMessage,
this, &MainWindow::slotSendChannelMessage);
connect(ui.initVideoButton, &QAbstractButton::clicked,
ui.actionEnableVideoTransmission, &QAction::triggered);
connect(ui.addVideoButton, &QAbstractButton::clicked, this, &MainWindow::slotAddUserVideo);
Expand All @@ -314,6 +321,11 @@ MainWindow::MainWindow(const QString& cfgfile)
connect(this, &MainWindow::preferencesModified,
ui.videogridWidget, &VideoGridWidget::preferencesModified);
/* Desktop-tab buttons */
connect(ui.desktopsendButton, &QAbstractButton::clicked,
this, &MainWindow::slotSendChannelMessage);
connect(ui.desktopmsgEdit, &QLineEdit::textChanged, this, &MainWindow::slotTextChanged);
connect(ui.desktopmsgEdit, &ChatLineEdit::sendTextMessage,
this, &MainWindow::slotSendChannelMessage);
connect(ui.detachDesktopButton, &QAbstractButton::clicked,
this, &MainWindow::slotDetachUserDesktopGrid);
connect(ui.addDesktopButton, &QAbstractButton::clicked,
Expand Down Expand Up @@ -1448,6 +1460,9 @@ void MainWindow::clienteventStreamMediaFile(const MediaFileInfo& mediafileinfo)

//update if still talking
emit(updateMyself());

//update media tab
updateMediaFileProgress(mediafileinfo);
}

void MainWindow::clienteventUserVideoCapture(int source, int streamid)
Expand Down Expand Up @@ -5419,6 +5434,43 @@ void MainWindow::slotPauseResumeStream()
TT_DoChangeStatus(ttInst, m_statusmode, _W(statusmsg));
}

void MainWindow::updateMediaFileProgress(const MediaFileInfo& mfi)
{
m_mfi = mfi;
switch (mfi.nStatus)
{
case MFS_CLOSED :
case MFS_ABORTED :
case MFS_ERROR :
case MFS_FINISHED :
ui.durationLabel->setText(durationToString(0));
ui.playbackTimeLabel->setText(durationToString(0));
ui.audioLabel->setText("");
ui.videoLabel->setText("");
break;
case MFS_PAUSED :
case MFS_STARTED :
case MFS_PLAYING :
ui.durationLabel->setText(durationToString(mfi.uDurationMSec));
ui.playbackTimeLabel->setText(durationToString(mfi.uElapsedMSec));
ui.audioLabel->setText(getMediaAudioDescription(mfi.audioFmt));
ui.videoLabel->setText(getMediaVideoDescription(mfi.videoFmt));
break;
}
}

void MainWindow::changeMediaFileOffset(int pos)
{
double percent = pos / double(ui.playbackOffsetSlider->maximum());

m_mfp.uOffsetMSec = UINT32(m_mfi.uDurationMSec * percent);
m_mfp.bPaused = false;
if (!TT_UpdateStreamingMediaFileToChannel(ttInst, &m_mfp, &m_mfp_videocodec))
{
QMessageBox::critical(this, MENUTEXT(ui.actionPauseResumeStream->text()), tr("Failed to change playback position"));
}
}

void MainWindow::slotChannelsUploadFile(bool /*checked =false */)
{
int channelid = m_filesmodel->getChannelID();
Expand Down
6 changes: 5 additions & 1 deletion Client/qtTeamTalk/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ enum TimerEvent
enum
{
TAB_CHAT,
TAB_FILES,
TAB_MEDIA,
TAB_VIDEO,
TAB_DESKTOP,
TAB_FILES,

TAB_COUNT
};
Expand Down Expand Up @@ -250,6 +251,8 @@ class MainWindow : public QMainWindow
void processDesktopInput(int userid, const DesktopInput& input);
void startStreamMediaFile();
void stopStreamMediaFile();
void updateMediaFileProgress(const MediaFileInfo& mfi);
void changeMediaFileOffset(int pos);
void loadHotKeys();
void enableHotKey(HotKeyID id, const hotkey_t& hk);
void disableHotKey(HotKeyID id);
Expand Down Expand Up @@ -472,6 +475,7 @@ class MainWindow : public QMainWindow
void clienteventSoundDeviceAdded(const SoundDevice& snddev);
void clienteventSoundDeviceRemoved(const SoundDevice& snddev);
MediaFilePlayback m_mfp = {};
MediaFileInfo m_mfi = {};
VideoCodec m_mfp_videocodec = {};

signals:
Expand Down
Loading

0 comments on commit 33c4d2d

Please sign in to comment.