Ticket #6497: mediac.diff
File mediac.diff, 3.7 KB (added by , 14 years ago) |
---|
-
src/apps/mediaconverter/MediaFileInfo.h
18 18 19 19 struct MediaFileInfo { 20 20 MediaFileInfo(BMediaFile* file = NULL); 21 voidLoadInfo(BMediaFile* file);21 status_t LoadInfo(BMediaFile* file); 22 22 23 23 MediaInfo audio; 24 24 MediaInfo video; -
src/apps/mediaconverter/MediaFileInfoView.cpp
4 4 // This file may be used under the terms of the Be Sample Code License. 5 5 #include "MediaFileInfoView.h" 6 6 7 #include <Alert.h> 7 8 #include <ControlLook.h> 8 9 #include <MediaFile.h> 9 10 #include <MediaTrack.h> … … 155 156 else 156 157 fRef = entry_ref(); 157 158 158 fInfo.LoadInfo(file); 159 status_t ret = fInfo.LoadInfo(file); 160 if (ret != B_OK) { 161 BString error("An error has occurred reading the " 162 "file info.\n\nError : "); 163 error << strerror(ret); 164 BAlert* alert = new BAlert("File Error", error.String(), 165 "OK"); 166 alert->Go(NULL); 167 } 159 168 160 169 InvalidateLayout(); 161 170 Invalidate(); -
src/apps/mediaconverter/MediaFileInfo.cpp
16 16 } 17 17 18 18 19 void 19 status_t 20 20 MediaFileInfo::LoadInfo(BMediaFile* file) 21 21 { 22 22 _Reset(); 23 23 if (!file) 24 return ;24 return B_BAD_VALUE; 25 25 26 26 BMediaTrack* track; 27 27 media_format format; … … 33 33 int32 tracks = file->CountTracks(); 34 34 int64 videoFrames = 0; 35 35 int64 audioFrames = 0; 36 status_t ret = B_OK; 37 36 38 for (int32 i = 0; i < tracks && (!audioDone || !videoDone); i++) { 37 39 track = file->TrackAt(i); 40 ret = track->InitCheck(); 41 if (ret != B_OK) 42 return ret; 43 38 44 if (track != NULL) { 39 track->EncodedFormat(&format); 45 ret = track->EncodedFormat(&format); 46 if (ret != B_OK) 47 return ret; 48 40 49 if (format.IsVideo()) { 41 50 memset(&format, 0, sizeof(format)); 42 51 format.type = B_MEDIA_RAW_VIDEO; 43 track->DecodedFormat(&format); 52 53 ret = track->DecodedFormat(&format); 54 if (ret != B_OK) 55 return ret; 56 44 57 media_raw_video_format *rvf = &(format.u.raw_video); 45 58 46 track->GetCodecInfo(&codecInfo); 59 ret = track->GetCodecInfo(&codecInfo); 60 if (ret != B_OK) 61 return ret; 62 47 63 video.format << codecInfo.pretty_name; 48 64 videoDuration = track->Duration(); 49 65 videoFrames = track->CountFrames(); … … 58 74 } else if (format.IsAudio()) { 59 75 memset(&format, 0, sizeof(format)); 60 76 format.type = B_MEDIA_RAW_AUDIO; 61 track->DecodedFormat(&format); 77 ret = track->DecodedFormat(&format); 78 if (ret != B_OK) 79 return ret; 80 62 81 media_raw_audio_format *raf = &(format.u.raw_audio); 63 82 char bytesPerSample = (char)(raf->format & 0xf); 64 83 if (bytesPerSample == 1) { … … 69 88 audio.details << bytesPerSample << "byte "; 70 89 } 71 90 72 track->GetCodecInfo(&codecInfo); 91 ret = track->GetCodecInfo(&codecInfo); 92 if (ret != B_OK) 93 return ret; 94 73 95 audio.format << codecInfo.pretty_name; 74 96 audioDuration = track->Duration(); 75 97 audioFrames = track->CountFrames(); … … 86 108 audio.details << audioFrames << " frames"; 87 109 audioDone = true; 88 110 } 89 file->ReleaseTrack(track); 90 } 111 ret = file->ReleaseTrack(track); 112 if (ret != B_OK) 113 return ret; 114 } 91 115 } 92 116 93 117 useconds = MAX(audioDuration, videoDuration); 94 118 duration << (int32)(useconds / 1000000) 95 119 << " seconds"; 120 121 return B_OK; 96 122 } 97 123 98 124