MythTV  master
Signals | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Static Private Attributes | Friends | List of all members
MythMediaDevice Class Referenceabstract

#include <mythmedia.h>

Inheritance diagram for MythMediaDevice:
Inheritance graph
[legend]
Collaboration diagram for MythMediaDevice:
Collaboration graph
[legend]

Signals

void statusChanged (MythMediaStatus oldStatus, MythMediaDevice *pMedia)
 

Public Member Functions

 MythMediaDevice (QObject *par, QString DevicePath, bool SuperMount, bool AllowEject)
 
const QString & getMountPath () const
 
void setMountPath (const char *path)
 
const QString & getDevicePath () const
 
const QString & getRealDevice () const
 
const QString & getDeviceModel () const
 
void setDeviceModel (const char *model)
 
MythMediaStatus getStatus () const
 
const QString & getVolumeID () const
 
void setVolumeID (const char *vol)
 
const QString & getKeyID () const
 
bool getAllowEject () const
 
bool getLocked () const
 
bool isDeviceOpen () const
 
bool isUsable () const
 Is this device "ready", for a plugin to access? More...
 
MythMediaType getMediaType () const
 
bool isSuperMount () const
 
virtual MythMediaError testMedia ()
 
virtual bool openDevice ()
 
virtual bool closeDevice ()
 
virtual bool isSameDevice (const QString &path)
 
virtual void setSpeed (int speed)
 
virtual void setDeviceSpeed (const char *, int)
 
virtual MythMediaStatus checkMedia ()=0
 
virtual MythMediaError eject (bool open_close=true)
 
virtual MythMediaError lock ()
 
virtual MythMediaError unlock ()
 
virtual bool performMountCmd (bool DoMount)
 
bool mount ()
 
bool unmount ()
 
bool isMounted (bool bVerify=true)
 Tells us if m_devicePath is a mounted device. More...
 
bool findMountPath ()
 Try to find a mount of m_devicePath in the mounts file. More...
 
void clearData ()
 
QString MediaTypeString ()
 

Static Public Member Functions

static void RegisterMediaExtensions (uint mediatype, const QString &extensions)
 Used to register media types with extensions. More...
 
static QString MediaTypeString (uint type)
 

Static Public Attributes

static const std::array< const QString, 9 > kMediaStatusStrings
 
static const std::array< const QString, 3 > kMediaErrorStrings
 

Protected Member Functions

 ~MythMediaDevice () override=default
 
virtual void onDeviceMounted (void)
 Override this to perform any post mount logic. More...
 
virtual void onDeviceUnmounted ()
 Override this to perform any post unmount logic. More...
 
MythMediaType DetectMediaType (void)
 Returns guessed media type based on file extensions. More...
 
bool ScanMediaType (const QString &directory, ext_cnt_t &cnt)
 Recursively scan directories and create an associative array with the number of times we've seen each extension. More...
 
MythMediaStatus setStatus (MythMediaStatus newStat, bool CloseIt=false)
 

Protected Attributes

QString m_deviceModel
 The device Manufacturer/Model. Read/write. More...
 
QString m_devicePath
 The path to this media's device. More...
 
QString m_keyID
 KeyID of the media. More...
 
QString m_mountPath
 The path to this media's mount point. More...
 
QString m_realDevice
 If m_devicePath is a symlink, its target. More...
 
QString m_volumeID
 The volume ID of the media. Read/write. More...
 
MythMediaStatus m_status {MEDIASTAT_UNKNOWN}
 The status of the media as of the last call to checkMedia. More...
 
MythMediaType m_mediaType {MEDIATYPE_UNKNOWN}
 The type of media. Read only. More...
 
bool m_allowEject
 Allow the user to eject the media?. Read only. More...
 
bool m_locked {false}
 Is this media locked?. Read only. More...
 
bool m_superMount
 Is this a supermount device?. More...
 
int m_deviceHandle {-1}
 A file handle for opening and closing the device, ioctls(), et c. More...
 

Static Private Attributes

static ext_to_media_t s_ext_to_media
 Map of extension to media type. More...
 

Friends

class MediaMonitorDarwin
 
class MonitorThreadDarwin
 

Detailed Description

Definition at line 48 of file mythmedia.h.

Constructor & Destructor Documentation

◆ MythMediaDevice()

MythMediaDevice::MythMediaDevice ( QObject *  par,
QString  DevicePath,
bool  SuperMount,
bool  AllowEject 
)

Definition at line 76 of file mythmedia.cpp.

◆ ~MythMediaDevice()

MythMediaDevice::~MythMediaDevice ( )
overrideprotecteddefault

Member Function Documentation

◆ getMountPath()

const QString& MythMediaDevice::getMountPath ( ) const
inline

◆ setMountPath()

void MythMediaDevice::setMountPath ( const char *  path)
inline

◆ getDevicePath()

const QString& MythMediaDevice::getDevicePath ( ) const
inline

◆ getRealDevice()

const QString& MythMediaDevice::getRealDevice ( ) const
inline

Definition at line 63 of file mythmedia.h.

Referenced by LookupModel(), and MediaMonitor::shouldIgnore().

◆ getDeviceModel()

const QString& MythMediaDevice::getDeviceModel ( ) const
inline

Definition at line 67 of file mythmedia.h.

Referenced by ImageManagerFe::DeviceEvent().

◆ setDeviceModel()

void MythMediaDevice::setDeviceModel ( const char *  model)
inline

◆ getStatus()

MythMediaStatus MythMediaDevice::getStatus ( ) const
inline

◆ getVolumeID()

const QString& MythMediaDevice::getVolumeID ( ) const
inline

Definition at line 72 of file mythmedia.h.

Referenced by ImageManagerFe::DeviceEvent(), and handleMedia().

◆ setVolumeID()

void MythMediaDevice::setVolumeID ( const char *  vol)
inline

◆ getKeyID()

const QString& MythMediaDevice::getKeyID ( ) const
inline

Definition at line 75 of file mythmedia.h.

◆ getAllowEject()

bool MythMediaDevice::getAllowEject ( ) const
inline

Definition at line 77 of file mythmedia.h.

◆ getLocked()

bool MythMediaDevice::getLocked ( ) const
inline

Definition at line 79 of file mythmedia.h.

◆ isDeviceOpen()

bool MythMediaDevice::isDeviceOpen ( ) const

◆ isUsable()

bool MythMediaDevice::isUsable ( ) const
inline

Is this device "ready", for a plugin to access?

Definition at line 84 of file mythmedia.h.

Referenced by MythCDROMLinux::checkMedia(), MediaMonitor::eventFilter(), and handleDVDMedia().

◆ getMediaType()

MythMediaType MythMediaDevice::getMediaType ( ) const
inline

◆ isSuperMount()

bool MythMediaDevice::isSuperMount ( ) const
inline

Definition at line 93 of file mythmedia.h.

◆ testMedia()

virtual MythMediaError MythMediaDevice::testMedia ( )
inlinevirtual

Reimplemented in MythCDROMLinux, and MythCDROMFreeBSD.

Definition at line 95 of file mythmedia.h.

Referenced by MediaMonitorUnix::AddDevice().

◆ openDevice()

bool MythMediaDevice::openDevice ( )
virtual

◆ closeDevice()

bool MythMediaDevice::closeDevice ( )
virtual

◆ isSameDevice()

bool MythMediaDevice::isSameDevice ( const QString &  path)
virtual

Reimplemented in MythCDROMLinux.

Definition at line 319 of file mythmedia.cpp.

◆ setSpeed()

void MythMediaDevice::setSpeed ( int  speed)
virtual

Definition at line 330 of file mythmedia.cpp.

Referenced by MediaMonitor::SetCDSpeed().

◆ setDeviceSpeed()

virtual void MythMediaDevice::setDeviceSpeed ( const char *  ,
int   
)
inlinevirtual

Reimplemented in MythCDROM, MythCDROMLinux, and MythCDROMDarwin.

Definition at line 100 of file mythmedia.h.

Referenced by setSpeed().

◆ checkMedia()

virtual MythMediaStatus MythMediaDevice::checkMedia ( )
pure virtual

Implemented in MythCDROMLinux, MythCDROM, and MythHDD.

Referenced by MediaMonitor::CheckDevices().

◆ eject()

MythMediaError MythMediaDevice::eject ( bool  open_close = true)
virtual

Reimplemented in MythHDD, MythCDROMLinux, and MythCDROMFreeBSD.

Definition at line 307 of file mythmedia.cpp.

Referenced by MediaMonitor::AttemptEject(), and Ripper::ejectCD().

◆ lock()

MythMediaError MythMediaDevice::lock ( )
virtual

Reimplemented in MythCDROMLinux, and MythCDROMFreeBSD.

Definition at line 335 of file mythmedia.cpp.

Referenced by MythCDROMFreeBSD::lock(), and MythCDROMLinux::lock().

◆ unlock()

MythMediaError MythMediaDevice::unlock ( )
virtual

◆ performMountCmd()

bool MythMediaDevice::performMountCmd ( bool  DoMount)
virtual

Definition at line 113 of file mythmedia.cpp.

◆ mount()

bool MythMediaDevice::mount ( )
inline

◆ unmount()

bool MythMediaDevice::unmount ( )
inline

Definition at line 108 of file mythmedia.h.

Referenced by MediaMonitor::AttemptEject(), MythCDROM::onDeviceMounted(), and setStatus().

◆ isMounted()

bool MythMediaDevice::isMounted ( bool  bVerify = true)

◆ findMountPath()

bool MythMediaDevice::findMountPath ( )

Try to find a mount of m_devicePath in the mounts file.

Definition at line 364 of file mythmedia.cpp.

Referenced by MediaMonitor::GetMountPath(), isMounted(), and performMountCmd().

◆ RegisterMediaExtensions()

void MythMediaDevice::RegisterMediaExtensions ( uint  mediatype,
const QString &  extensions 
)
static

Used to register media types with extensions.

Parameters
mediatypeMythMediaType flag.
extensionsComma separated list of extensions like 'mp3,ogg,flac'.

Definition at line 299 of file mythmedia.cpp.

Referenced by MediaMonitor::RegisterMediaHandler().

◆ clearData()

void MythMediaDevice::clearData ( )

Definition at line 507 of file mythmedia.cpp.

Referenced by MythHDD::checkMedia(), and MediaMonitor::mediaStatusChanged().

◆ MediaTypeString() [1/2]

QString MythMediaDevice::MediaTypeString ( )

◆ MediaTypeString() [2/2]

QString MythMediaDevice::MediaTypeString ( uint  type)
static

Definition at line 519 of file mythmedia.cpp.

◆ statusChanged

void MythMediaDevice::statusChanged ( MythMediaStatus  oldStatus,
MythMediaDevice pMedia 
)
signal

◆ onDeviceMounted()

virtual void MythMediaDevice::onDeviceMounted ( void  )
inlineprotectedvirtual

Override this to perform any post mount logic.

Reimplemented in MythCDROM.

Definition at line 133 of file mythmedia.h.

Referenced by MythHDD::checkMedia(), MythCDROM::onDeviceMounted(), and performMountCmd().

◆ onDeviceUnmounted()

virtual void MythMediaDevice::onDeviceUnmounted ( )
inlineprotectedvirtual

Override this to perform any post unmount logic.

Definition at line 141 of file mythmedia.h.

Referenced by performMountCmd().

◆ DetectMediaType()

MythMediaType MythMediaDevice::DetectMediaType ( void  )
protected

Returns guessed media type based on file extensions.

Definition at line 214 of file mythmedia.cpp.

◆ ScanMediaType()

bool MythMediaDevice::ScanMediaType ( const QString &  directory,
ext_cnt_t cnt 
)
protected

Recursively scan directories and create an associative array with the number of times we've seen each extension.

Definition at line 265 of file mythmedia.cpp.

Referenced by DetectMediaType().

◆ setStatus()

MythMediaStatus MythMediaDevice::setStatus ( MythMediaStatus  newStat,
bool  CloseIt = false 
)
protected

Friends And Related Function Documentation

◆ MediaMonitorDarwin

friend class MediaMonitorDarwin
friend

Definition at line 51 of file mythmedia.h.

◆ MonitorThreadDarwin

friend class MonitorThreadDarwin
friend

Definition at line 52 of file mythmedia.h.

Member Data Documentation

◆ kMediaStatusStrings

const std::array< const QString, 9 > MythMediaDevice::kMediaStatusStrings
static
Initial value:
{
"MEDIASTAT_ERROR",
"MEDIASTAT_UNKNOWN",
"MEDIASTAT_UNPLUGGED",
"MEDIASTAT_OPEN",
"MEDIASTAT_NODISK",
"MEDIASTAT_UNFORMATTED",
"MEDIASTAT_USEABLE",
"MEDIASTAT_NOTMOUNTED",
"MEDIASTAT_MOUNTED"
}

Definition at line 117 of file mythmedia.h.

Referenced by MythCDROMLinux::checkMedia(), MediaMonitor::mediaStatusChanged(), and setStatus().

◆ kMediaErrorStrings

const std::array< const QString, 3 > MythMediaDevice::kMediaErrorStrings
static
Initial value:
{
"MEDIAERR_OK",
"MEDIAERR_FAILED",
"MEDIAERR_UNSUPPORTED"
}

Definition at line 118 of file mythmedia.h.

◆ m_deviceModel

QString MythMediaDevice::m_deviceModel
protected

The device Manufacturer/Model. Read/write.

Definition at line 148 of file mythmedia.h.

◆ m_devicePath

QString MythMediaDevice::m_devicePath
protected

◆ m_keyID

QString MythMediaDevice::m_keyID
protected

KeyID of the media.

Read only (For ISO9660, volumeid + creation_date)

Definition at line 151 of file mythmedia.h.

Referenced by MythCDROMLinux::checkMedia(), and clearData().

◆ m_mountPath

QString MythMediaDevice::m_mountPath
protected

The path to this media's mount point.

(e.g. /mnt/cdrom) Read/write

Definition at line 153 of file mythmedia.h.

Referenced by MythHDD::checkMedia(), DetectMediaType(), findMountPath(), and MythCDROM::onDeviceMounted().

◆ m_realDevice

QString MythMediaDevice::m_realDevice
protected

If m_devicePath is a symlink, its target.

(e.g. /dev/hdc) Read only

Definition at line 155 of file mythmedia.h.

Referenced by findMountPath(), and MythMediaDevice().

◆ m_volumeID

QString MythMediaDevice::m_volumeID
protected

The volume ID of the media. Read/write.

Definition at line 157 of file mythmedia.h.

Referenced by MythHDD::checkMedia(), MythCDROMLinux::checkMedia(), and clearData().

◆ m_status

MythMediaStatus MythMediaDevice::m_status {MEDIASTAT_UNKNOWN}
protected

The status of the media as of the last call to checkMedia.

Read only

Definition at line 159 of file mythmedia.h.

Referenced by MythHDD::checkMedia(), MythCDROMLinux::checkMedia(), isMounted(), MythHDD::MythHDD(), MythCDROM::onDeviceMounted(), and setStatus().

◆ m_mediaType

MythMediaType MythMediaDevice::m_mediaType {MEDIATYPE_UNKNOWN}
protected

The type of media. Read only.

Definition at line 162 of file mythmedia.h.

Referenced by MythCDROMLinux::checkMedia(), clearData(), MediaTypeString(), MythHDD::MythHDD(), and MythCDROM::onDeviceMounted().

◆ m_allowEject

bool MythMediaDevice::m_allowEject
protected

Allow the user to eject the media?. Read only.

Definition at line 165 of file mythmedia.h.

Referenced by MythCDROMLinux::checkMedia(), and MythCDROM::onDeviceMounted().

◆ m_locked

bool MythMediaDevice::m_locked {false}
protected

Is this media locked?. Read only.

Definition at line 166 of file mythmedia.h.

Referenced by lock(), and unlock().

◆ m_superMount

bool MythMediaDevice::m_superMount
protected

Is this a supermount device?.

Read only The OS handles mounting/unmounting of 'supermount' devices. Myth only need to give derived classes a chance to perform their mount/unmount logic.

Definition at line 168 of file mythmedia.h.

Referenced by performMountCmd().

◆ m_deviceHandle

int MythMediaDevice::m_deviceHandle {-1}
protected

◆ s_ext_to_media

ext_to_media_t MythMediaDevice::s_ext_to_media
staticprivate

Map of extension to media type.

Definition at line 180 of file mythmedia.h.

Referenced by DetectMediaType(), and RegisterMediaExtensions().


The documentation for this class was generated from the following files: