Discman
Loading...
Searching...
No Matches
CDRipper Class Reference

Rips CDs and individual tracks to M4A files. More...

#include <cd_ripper.h>

Inheritance diagram for CDRipper:
Collaboration diagram for CDRipper:

Classes

struct  NoMedia
 Thrown when there is no removable volume to rip to. More...
 
struct  RipContext
 Contains resources that are shared by private helper functions. More...
 
struct  RipperErrorException
 Thrown when an error occurs mid-rip. More...
 

Public Types

typedef sigc::signal< void(unsigned int, unsigned int)> sig_track_progress
 "Track progress made" signal type.
 
typedef sigc::signal< void(void)> sig_done
 "Rip done" signal type.
 

Public Member Functions

sig_track_progress signal_track_progress ()
 Getter for ::_signal_track_progress.
 
sig_done signal_done ()
 Getter for ::_signal_done.
 
 CDRipper (CDDrive &drive, const DiscDB::Disc &disc, const std::string &albumArtURL, const std::string &mediaRoot)
 CDRipper constructor.
 
 ~CDRipper ()
 CDRipper destructor.
 
void rip ()
 Rip the entire disc.
 
void rip (const int track)
 Rip a specific track on the disc.
 
- Public Member Functions inherited from Consumer< int16_t >
 Consumer ()
 Consumer constructor.
 
virtual ~Consumer ()
 Consumer destructor.
 
virtual void producer (Producer< int16_t > *const producer)
 Sets the producer from which to retrieve data.
 

Private Member Functions

std::string make_safe (const std::string &str) const
 Used to sanitize folder and file names.
 
void on_notification ()
 Called when _dispatcher is notified.
 
void on_done_notification ()
 Called when _dispatcher_done is notified.
 
void rip_helper ()
 Private helper for rip().
 
void rip_helper (const int track)
 Private helper for rip(const int track).
 
void ensure_output_dir ()
 Verifies _media_root exists and sets _output_dir.
 
void start_rip (RipContext *rip_ctx)
 Begins the ripping process.
 
void do_rip (RipContext *rip_ctx, bool continuous=true)
 The core ripping method interacting directly with ffmpeg.
 
void end_rip (RipContext *rip_ctx)
 Ends the ripping process.
 
void start_file (RipContext *rip_ctx)
 Creates the ouput file, tags it and writes the M4A header.
 
void end_file (RipContext *rip_ctx)
 Frees resources in the ripping context specific to the output file.
 
void tag_file (RipContext *rip_ctx)
 Adds textual metadata (album and track information) to the output file.
 
void add_file_art (RipContext *rip_ctx)
 Adds _album_art_image to the output file.
 

Private Attributes

sig_track_progress _sig_track_progress
 Emitted when the percentage progress ripping a track has increased.
 
sig_done _sig_done
 Emiited when the rip (whole disc or single track) is done.
 
CDDrive_drive
 The parent CDDrive.
 
const DiscDB::Disc & _disc
 The fully populated DiscDB::Disc describing the album.
 
std::thread * _thread
 Used to execute the ripping process.
 
Glib::Dispatcher _dispatcher
 Used by _thread to safely emit _sig_track_progress.
 
Glib::Dispatcher _dispatcher_done
 Used by _thread to safely emit _sig_done.
 
unsigned int _track
 The 1-based index of the track currently being ripped.
 
unsigned int _progress
 The current percentage completion ripping the current track.
 
std::string _media_root
 The path to the root of the removable volume.
 
std::string _output_dir
 The path to the album folder on the removable volume.
 
std::string _output_filename
 The output filename.
 
std::string _album_art_url
 The URL of the album art currently shown.
 
uint8_t * _album_art_image
 Raw bytes received from the _album_art_url.
 
int _album_art_image_size
 The size of _album_art_image.
 
AVCodecID _album_art_image_codec
 Reflects whether the _album_art_image is JPEG or PNG.
 
std::pair< int, int > _album_art_image_dims
 The dimensions of _album_art_image in pixels.
 

Additional Inherited Members

- Protected Member Functions inherited from Consumer< int16_t >
int16_t consume () const
 Returns one datum from the producer.
 

Detailed Description

Rips CDs and individual tracks to M4A files.

See also
Producer/Consumer.

Definition at line 41 of file cd_ripper.h.

Member Typedef Documentation

◆ sig_done

typedef sigc::signal<void(void)> CDRipper::sig_done

"Rip done" signal type.

Definition at line 67 of file cd_ripper.h.

◆ sig_track_progress

typedef sigc::signal<void(unsigned int, unsigned int)> CDRipper::sig_track_progress

"Track progress made" signal type.

Definition at line 64 of file cd_ripper.h.

Constructor & Destructor Documentation

◆ CDRipper()

CDRipper::CDRipper ( CDDrive & drive,
const DiscDB::Disc & disc,
const std::string & albumArtURL,
const std::string & mediaRoot )

CDRipper constructor.

Parameters
[in]driveParent CDDrive.
[in]discFully populated DiscDB::Disc describing the album.
[in]albumArtURLURL to the currently shown album art.
[in]mediaRootPath to the root of the removable volume.

Definition at line 10 of file cd_ripper.cc.

◆ ~CDRipper()

CDRipper::~CDRipper ( )

CDRipper destructor.

Definition at line 26 of file cd_ripper.cc.

Member Function Documentation

◆ add_file_art()

void CDRipper::add_file_art ( RipContext * rip_ctx)
private

Adds _album_art_image to the output file.

Parameters
rip_ctxPointer to the ripping context.

Definition at line 387 of file cd_ripper.cc.

◆ do_rip()

void CDRipper::do_rip ( CDRipper::RipContext * rip_ctx,
bool continuous = true )
private

The core ripping method interacting directly with ffmpeg.

Parameters
[in]rip_ctxPointer to the ripping context.
[in]continuousWhether to continue ripping after the current track.

Definition at line 143 of file cd_ripper.cc.

◆ end_file()

void CDRipper::end_file ( RipContext * rip_ctx)
private

Frees resources in the ripping context specific to the output file.

Parameters
rip_ctxPointer to the ripping context.

Definition at line 303 of file cd_ripper.cc.

◆ end_rip()

void CDRipper::end_rip ( CDRipper::RipContext * rip_ctx)
private

Ends the ripping process.

Parameters
rip_ctxPointer to the ripping context.

Definition at line 233 of file cd_ripper.cc.

◆ ensure_output_dir()

void CDRipper::ensure_output_dir ( )
private

Verifies _media_root exists and sets _output_dir.

Definition at line 54 of file cd_ripper.cc.

◆ make_safe()

std::string CDRipper::make_safe ( const std::string & str) const
private

Used to sanitize folder and file names.

Parameters
[in]strA file or folder path component .
Returns
str with unsafe symbols replaced with underscores.

Definition at line 36 of file cd_ripper.cc.

◆ on_done_notification()

void CDRipper::on_done_notification ( )
private

Called when _dispatcher_done is notified.

Definition at line 50 of file cd_ripper.cc.

◆ on_notification()

void CDRipper::on_notification ( )
private

Called when _dispatcher is notified.

Definition at line 46 of file cd_ripper.cc.

◆ rip() [1/2]

void CDRipper::rip ( )

Rip the entire disc.

Definition at line 311 of file cd_ripper.cc.

◆ rip() [2/2]

void CDRipper::rip ( const int track)

Rip a specific track on the disc.

Parameters
[in]trackThe 1-based track index.

Definition at line 339 of file cd_ripper.cc.

◆ rip_helper() [1/2]

void CDRipper::rip_helper ( )
private

Private helper for rip().

Definition at line 322 of file cd_ripper.cc.

◆ rip_helper() [2/2]

void CDRipper::rip_helper ( const int track)
private

Private helper for rip(const int track).

Definition at line 350 of file cd_ripper.cc.

◆ signal_done()

CDRipper::sig_done CDRipper::signal_done ( )

Getter for ::_signal_done.

Definition at line 371 of file cd_ripper.cc.

◆ signal_track_progress()

CDRipper::sig_track_progress CDRipper::signal_track_progress ( )

Getter for ::_signal_track_progress.

Definition at line 367 of file cd_ripper.cc.

◆ start_file()

void CDRipper::start_file ( RipContext * rip_ctx)
private

Creates the ouput file, tags it and writes the M4A header.

Parameters
rip_ctxPointer to the ripping context.

Definition at line 238 of file cd_ripper.cc.

◆ start_rip()

void CDRipper::start_rip ( CDRipper::RipContext * rip_ctx)
private

Begins the ripping process.

Parameters
[in]rip_ctxPointer to the ripping context .

Definition at line 68 of file cd_ripper.cc.

◆ tag_file()

void CDRipper::tag_file ( RipContext * rip_ctx)
private

Adds textual metadata (album and track information) to the output file.

Parameters
rip_ctxPointer to the ripping context.

Definition at line 375 of file cd_ripper.cc.

Member Data Documentation

◆ _album_art_image

uint8_t* CDRipper::_album_art_image
private

Raw bytes received from the _album_art_url.

Definition at line 117 of file cd_ripper.h.

◆ _album_art_image_codec

AVCodecID CDRipper::_album_art_image_codec
private

Reflects whether the _album_art_image is JPEG or PNG.

Definition at line 119 of file cd_ripper.h.

◆ _album_art_image_dims

std::pair<int, int> CDRipper::_album_art_image_dims
private

The dimensions of _album_art_image in pixels.

Definition at line 120 of file cd_ripper.h.

◆ _album_art_image_size

int CDRipper::_album_art_image_size
private

The size of _album_art_image.

Definition at line 118 of file cd_ripper.h.

◆ _album_art_url

std::string CDRipper::_album_art_url
private

The URL of the album art currently shown.

Definition at line 116 of file cd_ripper.h.

◆ _disc

const DiscDB::Disc& CDRipper::_disc
private

The fully populated DiscDB::Disc describing the album.

Definition at line 107 of file cd_ripper.h.

◆ _dispatcher

Glib::Dispatcher CDRipper::_dispatcher
private

Used by _thread to safely emit _sig_track_progress.

Definition at line 109 of file cd_ripper.h.

◆ _dispatcher_done

Glib::Dispatcher CDRipper::_dispatcher_done
private

Used by _thread to safely emit _sig_done.

Definition at line 110 of file cd_ripper.h.

◆ _drive

CDDrive& CDRipper::_drive
private

The parent CDDrive.

Definition at line 106 of file cd_ripper.h.

◆ _media_root

std::string CDRipper::_media_root
private

The path to the root of the removable volume.

Definition at line 113 of file cd_ripper.h.

◆ _output_dir

std::string CDRipper::_output_dir
private

The path to the album folder on the removable volume.

Definition at line 114 of file cd_ripper.h.

◆ _output_filename

std::string CDRipper::_output_filename
private

The output filename.

Definition at line 115 of file cd_ripper.h.

◆ _progress

unsigned int CDRipper::_progress
private

The current percentage completion ripping the current track.

Definition at line 112 of file cd_ripper.h.

◆ _sig_done

sig_done CDRipper::_sig_done
private

Emiited when the rip (whole disc or single track) is done.

Definition at line 104 of file cd_ripper.h.

◆ _sig_track_progress

sig_track_progress CDRipper::_sig_track_progress
private

Emitted when the percentage progress ripping a track has increased.

Definition at line 103 of file cd_ripper.h.

◆ _thread

std::thread* CDRipper::_thread
private

Used to execute the ripping process.

Definition at line 108 of file cd_ripper.h.

◆ _track

unsigned int CDRipper::_track
private

The 1-based index of the track currently being ripped.

Definition at line 111 of file cd_ripper.h.


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