syntax = "proto2";

package spb.tagreader;

message SongMetadata {

  enum FileType {
    UNKNOWN = 0;
    WAV = 1;
    FLAC = 2;
    WAVPACK = 3;
    OGGFLAC = 4;
    OGGVORBIS = 5;
    OGGOPUS = 6;
    OGGSPEEX = 7;
    MPEG = 8;
    MP4 = 9;
    ASF = 10;
    AIFF = 11;
    MPC = 12;
    TRUEAUDIO = 13;
    DSF = 14;
    DSDIFF = 15;
    PCM = 16;
    APE = 17;
    MOD = 18;
    S3M = 19;
    XM = 20;
    IT = 21;
    SPC = 22;
    VGM = 23;
    CDDA = 90;
    STREAM = 91;
  }

  optional bool valid = 1;

  optional string title = 2;
  optional string album = 3;
  optional string artist = 4;
  optional string albumartist = 5;
  optional int32 track = 6;
  optional int32 disc = 7;
  optional int32 year = 8;
  optional int32 originalyear = 9;
  optional string genre = 10;
  optional bool compilation = 11;
  optional string composer = 12;
  optional string performer = 13;
  optional string grouping = 14;
  optional string comment = 15;
  optional string lyrics = 16;

  optional uint64 length_nanosec = 17;

  optional int32 bitrate = 18;
  optional int32 samplerate = 19;
  optional int32 bitdepth = 20;

  optional string url = 21;
  optional string basefilename = 22;
  optional FileType filetype = 23;
  optional int64 filesize = 24;
  optional int64 mtime = 25;
  optional int64 ctime = 26;

  optional uint32 playcount = 27;
  optional uint32 skipcount = 28;
  optional int64 lastplayed = 29;
  optional int64 lastseen = 30;

  optional bool art_embedded = 31;

  optional float rating = 32;

  optional string acoustid_id = 33;
  optional string acoustid_fingerprint = 34;

  optional string musicbrainz_album_artist_id = 35;     // MusicBrainz Release Artist ID (MUSICBRAINZ_ALBUMARTISTID)
  optional string musicbrainz_artist_id = 36;           // MusicBrainz Artist ID (MUSICBRAINZ_ARTISTID)
  optional string musicbrainz_original_artist_id = 37;  // MusicBrainz Original Artist ID (MUSICBRAINZ_ORIGINALARTISTID)
  optional string musicbrainz_album_id = 38;            // MusicBrainz Release ID (MUSICBRAINZ_ALBUMID)
  optional string musicbrainz_original_album_id = 39;   // MusicBrainz Original Release ID (MUSICBRAINZ_ORIGINALALBUMID)
  optional string musicbrainz_recording_id = 40;        // MusicBrainz Recording ID (MUSICBRAINZ_TRACKID)
  optional string musicbrainz_track_id = 41;            // MusicBrainz Track ID (MUSICBRAINZ_RELEASETRACKID)
  optional string musicbrainz_disc_id = 42;             // MusicBrainz Disc ID (MUSICBRAINZ_DISCID)
  optional string musicbrainz_release_group_id = 43;    // MusicBrainz Release Group ID (MUSICBRAINZ_RELEASEGROUPID)
  optional string musicbrainz_work_id = 44;             // MusicBrainz Work ID (MUSICBRAINZ_WORKID)

  optional bool suspicious_tags = 50;

}

message IsMediaFileRequest {
  optional string filename = 1;
}

message IsMediaFileResponse {
  optional bool success = 1;
  optional string error = 2;
}

message ReadFileRequest {
  optional string filename = 1;
}

message ReadFileResponse {
  optional SongMetadata metadata = 1;
  optional string error = 2;
}

message SaveFileRequest {
  optional string filename = 1;
  optional bool save_tags = 2;
  optional bool save_playcount = 3;
  optional bool save_rating = 4;
  optional bool save_cover = 5;
  optional SongMetadata metadata = 6;
  optional string cover_filename = 7;
  optional bytes cover_data = 8;
  optional string cover_mime_type = 9;
}

message SaveFileResponse {
  optional bool success = 1;
  optional string error = 2;
}

message LoadEmbeddedArtRequest {
  optional string filename = 1;
}

message LoadEmbeddedArtResponse {
  optional bytes data = 1;
  optional string error = 2;
}

message SaveEmbeddedArtRequest {
  optional string filename = 1;
  optional string cover_filename = 2;
  optional bytes cover_data = 3;
  optional string cover_mime_type = 4;
}

message SaveEmbeddedArtResponse {
  optional bool success = 1;
  optional string error = 2;
}

message SaveSongPlaycountToFileRequest {
  optional string filename = 1;
  optional SongMetadata metadata = 2;
}

message SaveSongPlaycountToFileResponse {
  optional bool success = 1;
  optional string error = 2;
}

message SaveSongRatingToFileRequest {
  optional string filename = 1;
  optional SongMetadata metadata = 2;
}

message SaveSongRatingToFileResponse {
  optional bool success = 1;
  optional string error = 2;
}

message Message {
  optional int32 id = 1;

  optional ReadFileRequest read_file_request = 2;
  optional ReadFileResponse read_file_response = 3;

  optional SaveFileRequest save_file_request = 4;
  optional SaveFileResponse save_file_response = 5;

  optional IsMediaFileRequest is_media_file_request = 6;
  optional IsMediaFileResponse is_media_file_response = 7;

  optional LoadEmbeddedArtRequest load_embedded_art_request = 8;
  optional LoadEmbeddedArtResponse load_embedded_art_response = 9;

  optional SaveEmbeddedArtRequest save_embedded_art_request = 10;
  optional SaveEmbeddedArtResponse save_embedded_art_response = 11;

  optional SaveSongPlaycountToFileRequest save_song_playcount_to_file_request = 12;
  optional SaveSongPlaycountToFileResponse save_song_playcount_to_file_response = 13;

  optional SaveSongRatingToFileRequest save_song_rating_to_file_request = 14;
  optional SaveSongRatingToFileResponse save_song_rating_to_file_response = 15;

}
