本文整理汇总了C++中BMediaTrack::EncodedFormat方法的典型用法代码示例。如果您正苦于以下问题:C++ BMediaTrack::EncodedFormat方法的具体用法?C++ BMediaTrack::EncodedFormat怎么用?C++ BMediaTrack::EncodedFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BMediaTrack
的用法示例。
在下文中一共展示了BMediaTrack::EncodedFormat方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Video
/* FUNCTION: Video :: Video
ARGUMENTS: ref
RETURN: n/a
DESCRIPTION: Constructor
*/
Video :: Video(entry_ref *ref)
{
fMediaFile = 0;
fVideoTrack = 0;
fBitmap = 0;
fVideoThread = 0;
fMediaFile = new BMediaFile(ref, B_MEDIA_FILE_BIG_BUFFERS);
fStatus = fMediaFile->InitCheck();
if (fStatus != B_OK)
return;
int32 num_tracks = fMediaFile->CountTracks();
for (int32 i=0; i < num_tracks; i++)
{
BMediaTrack *track = fMediaFile->TrackAt(i);
if (track == NULL)
{
fMediaFile->ReleaseAllTracks();
printf("Media file claims to have %ld tracks, cannot find track %ld\n", num_tracks, i);
fVideoTrack = 0;
return;
}
media_format mf;
fStatus = track->EncodedFormat(&mf);
if (fStatus == B_OK)
{
switch (mf.type)
{
case B_MEDIA_ENCODED_VIDEO:
case B_MEDIA_RAW_VIDEO:
if (fVideoTrack == 0)
{
fVideoTrack = track;
InitPlayer(&mf);
}
else
printf("Multiple video tracks not supported\n");
break;
default:
fStatus = B_ERROR;
}
}
if (fStatus != B_OK)
fMediaFile->ReleaseTrack(track);
}
if (fVideoTrack)
fStatus = B_OK;
}
示例2: audioDone
void
MediaFileInfoView::_GetFileInfo(BString* audioFormat, BString* videoFormat,
BString* audioDetails, BString* videoDetails, BString* duration)
{
fDuration = 0;
if (fMediaFile == NULL)
return;
BMediaTrack* track;
media_format format;
memset(&format, 0, sizeof(format));
media_codec_info codecInfo;
bool audioDone(false), videoDone(false);
bigtime_t audioDuration = 0;
bigtime_t videoDuration = 0;
int32 tracks = fMediaFile->CountTracks();
int64 videoFrames = 0;
int64 audioFrames = 0;
for (int32 i = 0; i < tracks && (!audioDone || !videoDone); i++) {
track = fMediaFile->TrackAt(i);
if (track != NULL) {
track->EncodedFormat(&format);
if (format.IsVideo()) {
memset(&format, 0, sizeof(format));
format.type = B_MEDIA_RAW_VIDEO;
track->DecodedFormat(&format);
media_raw_video_format *rvf = &(format.u.raw_video);
track->GetCodecInfo(&codecInfo);
*videoFormat << codecInfo.pretty_name;
videoDuration = track->Duration();
videoFrames = track->CountFrames();
*videoDetails << (int32)format.Width() << "x" << (int32)format.Height()
<< " " << (int32)(rvf->field_rate / rvf->interlace)
<< " fps / " << videoFrames << " frames";
videoDone = true;
} else if (format.IsAudio()) {
memset(&format, 0, sizeof(format));
format.type = B_MEDIA_RAW_AUDIO;
track->DecodedFormat(&format);
media_raw_audio_format *raf = &(format.u.raw_audio);
char bytesPerSample = (char)(raf->format & 0xf);
if (bytesPerSample == 1) {
*audioDetails << "8 bit ";
} else if (bytesPerSample == 2) {
*audioDetails << "16 bit ";
} else {
*audioDetails << bytesPerSample << "byte ";
}
track->GetCodecInfo(&codecInfo);
*audioFormat << codecInfo.pretty_name;
audioDuration = track->Duration();
audioFrames = track->CountFrames();
*audioDetails << (float)(raf->frame_rate / 1000.0f) << " kHz";
if (raf->channel_count == 1) {
*audioDetails << " mono / ";
} else if (raf->channel_count == 2) {
*audioDetails << " stereo / ";
} else {
*audioDetails << (int32)raf->channel_count << " channel / " ;
}
*audioDetails << audioFrames << " frames";
audioDone = true;
}
fMediaFile->ReleaseTrack(track);
}
}
fDuration = MAX(audioDuration, videoDuration);
*duration << (int32)(fDuration / 1000000)
<< " seconds";
}
示例3: videoBounds
// Init
status_t
VideoClip::Init(const entry_ref* ref)
{
// check if this file is a MediaFile
// instantiate a BMediaFile object, and make sure there was no error.
fMediaFile = new BMediaFile(ref);
status_t err = fMediaFile->InitCheck();
if (err < B_OK) {
fprintf(stderr, "VideoClip::Init() - "
"no media file: %s\n", strerror(err));
return err;
}
// count the tracks and instanciate them, one at a time
int32 numTracks = fMediaFile->CountTracks();
for (int32 i = 0; i < numTracks; i++) {
if (fTrack)
break;
BMediaTrack* track = fMediaFile->TrackAt(i);
if (!track) {
fprintf(stderr, "VideoClip::Init() - "
"cannot read media track at %ld\n", i);
continue;
}
// get the encoded format
media_format format;
err = track->EncodedFormat(&format);
if (err < B_OK) {
fprintf(stderr, "VideoClip::Init() - "
"cannot understand encoded format "
"of track %ld: %s\n", i, strerror(err));
continue;
}
switch(format.type) {
case B_MEDIA_RAW_VIDEO:
case B_MEDIA_ENCODED_VIDEO: {
// video track
fTrack = track;
break;
}
case B_MEDIA_RAW_AUDIO:
// audio track
break;
case B_MEDIA_ENCODED_AUDIO:
// audio track
break;
default:
break;
}
if (fTrack != track) {
// didn't do anything with the track
fMediaFile->ReleaseTrack(track);
}
}
if (!fTrack)
return B_UNSUPPORTED;
err = fTrack->EncodedFormat(&fFormat);
if (err < B_OK) {
fprintf(stderr, "VideoClip::Init() - "
"fTrack->EncodedFormat(): %s\n",
strerror(err));
return err;
}
// get encoded video frame size
uint32 width = fFormat.u.encoded_video.output.display.line_width;
uint32 height = fFormat.u.encoded_video.output.display.line_count;
printf("VideoClip::Init() - native colorspace: %s\n",
string_for_color_space(fFormat.u.encoded_video.output.display.format));
// allocate a buffer large enough to contain the decoded frame.
BRect videoBounds(0.0, 0.0, width - 1, height - 1);
fBuffer = new BBitmap(videoBounds, 0, B_YCbCr422);
err = fBuffer->InitCheck();
if (err < B_OK) {
fprintf(stderr, "VideoClip::Init() - "
"error allocating buffer: %s\n",
strerror(err));
delete fBuffer;
fBuffer = NULL;
return err;
}
// specifiy the decoded format. we derive this information from
// the encoded format.
memset(&fFormat, 0, sizeof(media_format));
fFormat.u.raw_video.last_active = height - 1;
// fFormat.u.raw_video.orientation = B_VIDEO_TOP_LEFT_RIGHT;
// fFormat.u.raw_video.pixel_width_aspect = 1;
// fFormat.u.raw_video.pixel_height_aspect = 1;
fFormat.u.raw_video.display.format = fBuffer->ColorSpace();
fFormat.u.raw_video.display.line_width = width;
fFormat.u.raw_video.display.line_count = height;
fFormat.u.raw_video.display.bytes_per_row = fBuffer->BytesPerRow();
//.........这里部分代码省略.........
示例4: entry
void
VideoFileTexture::_Load(const char* fileName)
{
BEntry entry(fileName);
entry_ref ref;
entry.GetRef(&ref);
fMediaFile = new BMediaFile(&ref);
status_t err = fMediaFile->InitCheck();
if (err != B_OK) {
printf("cannot contruct BMediaFile object -- %s\n", strerror(err));
return;
}
int32 trackCount = fMediaFile->CountTracks();
for (int32 i = 0; i < trackCount; i++) {
BMediaTrack* track = fMediaFile->TrackAt(i);
if (track == NULL) {
printf("cannot contruct BMediaTrack object\n");
return;
}
// get the encoded format
media_format format;
err = track->EncodedFormat(&format);
if (err != B_OK) {
printf("BMediaTrack::EncodedFormat error -- %s\n", strerror(err));
return;
}
if (format.type == B_MEDIA_ENCODED_VIDEO) {
fVideoTrack = track;
// allocate a bitmap large enough to contain the decoded frame.
BRect bounds(0.0, 0.0,
format.u.encoded_video.output.display.line_width - 1.0,
format.u.encoded_video.output.display.line_count - 1.0);
fVideoBitmap = new BBitmap(bounds, B_RGB32);
// specifiy the decoded format. we derive this information from
// the encoded format.
memset(&format, 0, sizeof(media_format));
format.u.raw_video.last_active = (int32) (bounds.Height() - 1.0);
format.u.raw_video.orientation = B_VIDEO_TOP_LEFT_RIGHT;
format.u.raw_video.pixel_width_aspect = 1;
format.u.raw_video.pixel_height_aspect = 3;
format.u.raw_video.display.format = fVideoBitmap->ColorSpace();
format.u.raw_video.display.line_width = (int32) bounds.Width();
format.u.raw_video.display.line_count = (int32) bounds.Height();
format.u.raw_video.display.bytes_per_row
= fVideoBitmap->BytesPerRow();
err = fVideoTrack->DecodedFormat(&format);
if (err != B_OK) {
printf("error with BMediaTrack::DecodedFormat() -- %s\n",
strerror(err));
return;
}
// Create Texture
glGenTextures(1, &fId);
glBindTexture(GL_TEXTURE_2D, fId);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 4,
(int) fVideoBitmap->Bounds().Width() + 1,
(int) fVideoBitmap->Bounds().Height() + 1,
0, GL_BGRA, GL_UNSIGNED_BYTE, fVideoBitmap->Bits());
}
}
}
示例5: MessageReceived
void LeftList::MessageReceived(BMessage* msg)
{
struct AudioInfo fAudioInfo;
BMediaFile* testfile;
bool fIsAudio = false;
BMediaTrack* track;
media_codec_info codecInfo;
media_format format;
memset(&format, 0, sizeof(format));
entry_ref ref;
int32 counter = 0;
switch (msg->what) {
case B_SIMPLE_DATA:
while (msg->FindRef("refs", counter++, &ref) == B_OK) {
if ((testfile = new BMediaFile(&ref)) != NULL) {
testfile->InitCheck();
track = testfile->TrackAt(0);
if (track != NULL) {
track->EncodedFormat(&format);
if (format.IsAudio()) {
memset(&format, 0, sizeof(format));
format.type = B_MEDIA_RAW_AUDIO;
track->DecodedFormat(&format);
fAudioInfo.total_time = track->Duration();
media_raw_audio_format* raf = &(format.u.raw_audio);
fAudioInfo.bps = (int32)(raf->format & 0xf);
fAudioInfo.frame_rate = (int32)raf->frame_rate;
fAudioInfo.channels = (int32)raf->channel_count;
track->GetCodecInfo(&codecInfo);
strcpy(fAudioInfo.pretty_name, codecInfo.pretty_name);
strcpy(fAudioInfo.short_name, codecInfo.short_name);
fIsAudio = true;
}
}
} else
WriteLog("MediaFile NULL (file doesnt exists!?)");
delete testfile;
if (fIsAudio) {
if (!strcmp(fAudioInfo.pretty_name, "Raw Audio") && (fAudioInfo.channels == 2) && (fAudioInfo.frame_rate == 44100) && (fAudioInfo.bps == 2))
AddItem(new LeftListItem(&ref, ref.name, fAudioBitmap, &fAudioInfo));
else {
BAlert* MyAlert = new BAlert("BurnItNow", "You can only burn 16 bits stereo 44.1 kHz Raw Audio files.\n (More audio files will be supported in the future)", "Ok", NULL, NULL, B_WIDTH_AS_USUAL, B_INFO_ALERT);
MyAlert->Go();
}
} else {
BPath temp_path;
BEntry(&ref).GetPath(&temp_path);
jpWindow* win = dynamic_cast<jpWindow*>(Window());
if (win != NULL)
win->SetISOFile((char*)temp_path.Path());
}
}
break;
default:
BListView::MessageReceived(msg);
break;
}
}
示例6: audioDone
status_t
MediaFileInfo::LoadInfo(BMediaFile* file)
{
_Reset();
if (!file)
return B_BAD_VALUE;
BMediaTrack* track;
media_format format;
memset(&format, 0, sizeof(format));
media_codec_info codecInfo;
bool audioDone(false), videoDone(false);
bigtime_t audioDuration = 0;
bigtime_t videoDuration = 0;
int32 tracks = file->CountTracks();
int64 videoFrames = 0;
int64 audioFrames = 0;
status_t ret = B_OK;
for (int32 i = 0; i < tracks && (!audioDone || !videoDone); i++) {
track = file->TrackAt(i);
if (track == NULL)
return B_ERROR;
ret = track->InitCheck();
if (ret != B_OK)
return ret;
ret = track->EncodedFormat(&format);
if (ret != B_OK)
return ret;
if (format.IsVideo()) {
memset(&format, 0, sizeof(format));
format.type = B_MEDIA_RAW_VIDEO;
ret = track->DecodedFormat(&format);
if (ret != B_OK)
return ret;
media_raw_video_format *rvf = &(format.u.raw_video);
ret = track->GetCodecInfo(&codecInfo);
if (ret != B_OK)
return ret;
video.format << codecInfo.pretty_name;
videoDuration = track->Duration();
videoFrames = track->CountFrames();
BString details;
snprintf(details.LockBuffer(256), 256,
B_TRANSLATE_COMMENT("%u x %u, %.2ffps / %Ld frames",
"Width x Height, fps / frames"),
format.Width(), format.Height(),
rvf->field_rate / rvf->interlace, videoFrames);
details.UnlockBuffer();
video.details << details;
videoDone = true;
} else if (format.IsAudio()) {
memset(&format, 0, sizeof(format));
format.type = B_MEDIA_RAW_AUDIO;
ret = track->DecodedFormat(&format);
if (ret != B_OK)
return ret;
media_raw_audio_format *raf = &(format.u.raw_audio);
char bytesPerSample = (char)(raf->format & 0xf);
BString details;
if (bytesPerSample == 1 || bytesPerSample == 2) {
snprintf(details.LockBuffer(16), 16,
B_TRANSLATE("%d bit "), bytesPerSample * 8);
} else {
snprintf(details.LockBuffer(16), 16,
B_TRANSLATE("%d byte "), bytesPerSample);
}
details.UnlockBuffer();
audio.details << details;
ret = track->GetCodecInfo(&codecInfo);
if (ret != B_OK)
return ret;
audio.format << codecInfo.pretty_name;
audioDuration = track->Duration();
audioFrames = track->CountFrames();
BString channels;
if (raf->channel_count == 1) {
snprintf(channels.LockBuffer(64), 64,
B_TRANSLATE("%.1f kHz mono / %lld frames"),
raf->frame_rate / 1000.f, audioFrames);
} else if (raf->channel_count == 2) {
snprintf(channels.LockBuffer(64), 64,
B_TRANSLATE("%.1f kHz stereo / %lld frames"),
raf->frame_rate / 1000.f, audioFrames);
} else {
snprintf(channels.LockBuffer(64), 64,
B_TRANSLATE("%.1f kHz %ld channel / %lld frames"),
raf->frame_rate / 1000.f, raf->channel_count, audioFrames);
//.........这里部分代码省略.........
示例7: BMediaFile
// GetMedia
status_t
MediaClip::_GetMedia(const entry_ref* ref, BMediaFile*& mediaFile,
BMediaTrack** _videoTrack, BMediaTrack** _audioTrack)
{
if (_videoTrack != NULL)
*_videoTrack = NULL;
if (_audioTrack != NULL)
*_audioTrack = NULL;
mediaFile = new BMediaFile(ref);
status_t status = mediaFile->InitCheck();
if (status < B_OK) {
delete mediaFile;
mediaFile = NULL;
return status;
}
// count the tracks and instantiate them, one at a time
int32 numTracks = mediaFile->CountTracks();
for (int32 i = 0; i < numTracks; i++) {
BMediaTrack* track = mediaFile->TrackAt(i);
if (track == NULL) {
printf("cannot read media track at %ld\n", i);
continue;
}
// get the encoded format
media_format format;
status = track->EncodedFormat(&format);
if (status < B_OK) {
printf("cannot understand encoded format "
"of track %ld: %s\n", i, strerror(status));
continue;
}
bool release = true;
switch (format.type) {
case B_MEDIA_RAW_VIDEO:
case B_MEDIA_ENCODED_VIDEO: {
// video track
if (_videoTrack != NULL && *_videoTrack == NULL) {
*_videoTrack = track;
release = false;
}
break;
}
case B_MEDIA_RAW_AUDIO:
case B_MEDIA_ENCODED_AUDIO:
// audio track
if (_audioTrack != NULL && *_audioTrack == NULL) {
*_audioTrack = track;
release = false;
}
break;
default:
break;
}
if (release) {
// didn't do anything with the track
mediaFile->ReleaseTrack(track);
}
}
return B_OK;
}
示例8: autolock
status_t
MediaView::SetMediaSource(BPositionIO *data)
{
BAutolock autolock(Window());
fMediaFile = new BMediaFile(data);
file = data;
bool foundTrack = false;
int32 numTracks = fMediaFile->CountTracks();
for (int32 i = 0; i < numTracks; i++) {
BMediaTrack *track = fMediaFile->TrackAt(i);
if (track == NULL) {
Reset();
return (B_ERROR);
}
else {
bool trackUsed = false;
media_format mf;
if (track->EncodedFormat(&mf) == B_NO_ERROR) {
switch (mf.type) {
case B_MEDIA_ENCODED_VIDEO:
printf("#################field rate %f\n", mf.u.encoded_video.output.field_rate);
trackUsed = SetVideoTrack(data, track, &mf) == B_NO_ERROR;
break;
case B_MEDIA_RAW_AUDIO:
trackUsed = SetAudioTrack(data, track, &mf) == B_NO_ERROR;
break;
case B_MEDIA_ENCODED_AUDIO:
if (track->DecodedFormat(&mf) == B_NO_ERROR)
trackUsed = SetAudioTrack(data, track, &mf) == B_NO_ERROR;
break;
default:
break;
}
}
if (trackUsed)
foundTrack = true;
else {
fMediaFile->ReleaseTrack(track);
}
}
}
if (foundTrack) {
status_t err = B_ERROR;
fPlayerThread = spawn_thread(MediaView::MediaPlayer,
"MediaView::MediaPlayer",
95,
this);
if (fPlayerThread < B_NO_ERROR) {
err = fPlayerThread;
fPlayerThread = B_ERROR;
Reset();
return (err);
}
fPlaySem = create_sem(0, "MediaView::fPlaySem");
if (fPlaySem < B_NO_ERROR) {
err = fPlaySem;
fPlaySem = B_ERROR;
Reset();
return (err);
}
err = resume_thread(fPlayerThread);
if (err != B_NO_ERROR) {
kill_thread(fPlayerThread);
fPlayerThread = B_ERROR;
Reset();
return (err);
}
if (fVideoTrack != NULL)
fMediaBar->SetTotalTime(fVideoTrack->Duration());
else
fMediaBar->SetTotalTime(fAudioTrack->Duration());
}
return (B_NO_ERROR);
}
示例9: RefsReceived
void MyApplication::RefsReceived(BMessage *message)
{
// be_app->Lock();
uint32 ref_num;
entry_ref ref;
BMediaTrack *audTrack(NULL);
media_format format;
memset(&format, 0, sizeof(format));
// media_raw_audio_format *raf(NULL);
// short audioFrameSize(1);
// char *audioData(NULL);
int32 frame_size, channels = 1;
Pool.sample_type = NONE; // for frame moving / resize
bool temp_pause = play_cookie.pause;;
ref_num=0;
if (message->FindRef("refs",ref_num, &ref) == B_OK){
BMediaFile inFile(&ref);
if (inFile.InitCheck() == B_OK){
char s[B_FILE_NAME_LENGTH +20];
sprintf(s, "BeAE - %s", ref.name);
mainWindow->SetTitle(s);
Pool.sample_view_dirty = true; // update the sample-view
Pool.update_index = true;
Pool.RedrawWindow();
play_cookie.pause = true;
// gather the necessary format information
int32 tracks = inFile.CountTracks();
for (int32 i = 0; i < tracks; i++) {
BMediaTrack *inTrack = inFile.TrackAt(i);
inTrack->EncodedFormat(&format);
if (format.IsAudio()) {
audTrack = inTrack;
inTrack->DecodedFormat(&format);
// Pool.m_format = format;
memcpy(&Pool.m_format, &format, sizeof(Pool.m_format));
Pool.sample_bits = (format.u.raw_audio.format & 0xf)*8;
Pool.selection = NONE;
Pool.frequency = format.u.raw_audio.frame_rate;
// printf("format : %x\n", format.u.raw_audio.format);
Pool.size = audTrack->CountFrames()-1;
channels = format.u.raw_audio.channel_count;
Pool.StartProgress(Language.get("LOADING_FILE"), Pool.size);
frame_size = (format.u.raw_audio.format & 0xf)*channels;
#ifndef __VM_SYSTEM //RAM
if (Pool.sample_memory) // create buffer for sample memory, add an extra frame to be able to do
free(Pool.sample_memory); // 32bit to 16 bit conversions
Pool.sample_memory = (float*)malloc(Pool.size * channels *4 +1024);
#endif
}else{
inFile.ReleaseAllTracks();
}
}
int64 frameCount, framesRead;
status_t err;
media_header mh;
int32 lastPercent, currPercent;
float completePercent;
BString status;
char *buffer = (char*)malloc(format.u.raw_audio.buffer_size); // temp memory
#ifndef __VM_SYSTEM //RAM
float *mem = Pool.sample_memory; // dest memory
// read audio from source and write to destination, if necessary
if (mem) {
#else
VM.Reset();
float *convert_buffer = (float*)malloc(format.u.raw_audio.buffer_size*4); // make sure there can be floats in it
// read audio from source and write to destination, if necessary
if (convert_buffer) {
float *mem = NULL;
#endif
frameCount = audTrack->CountFrames();
int64 count =0;
lastPercent = -1;
for (int64 i = 0; i < frameCount; i += framesRead) {
#ifdef __VM_SYSTEM //RAM
mem = convert_buffer;
#endif
// clear buffer first
memset( buffer, 0, format.u.raw_audio.buffer_size);
if ((err = audTrack->ReadFrames(buffer, &framesRead, &mh)) != B_OK) {
//.........这里部分代码省略.........
示例10: sizeof
status_t
MediaConverterApp::_ConvertFile(BMediaFile* inFile, BMediaFile* outFile,
media_codec_info* audioCodec, media_codec_info* videoCodec,
int32 audioQuality, int32 videoQuality,
bigtime_t startDuration, bigtime_t endDuration)
{
BMediaTrack* inVidTrack = NULL;
BMediaTrack* inAudTrack = NULL;
BMediaTrack* outVidTrack = NULL;
BMediaTrack* outAudTrack = NULL;
media_format inFormat;
media_format outAudFormat;
media_format outVidFormat;
media_raw_audio_format* raf = NULL;
media_raw_video_format* rvf = NULL;
int32 width = -1;
int32 height = -1;
uint8* videoBuffer = NULL;
uint8* audioBuffer = NULL;
// gather the necessary format information and construct output tracks
int64 videoFrameCount = 0;
int64 audioFrameCount = 0;
status_t ret = B_OK;
int32 tracks = inFile->CountTracks();
for (int32 i = 0; i < tracks && (!outAudTrack || !outVidTrack); i++) {
BMediaTrack* inTrack = inFile->TrackAt(i);
memset(&inFormat, 0, sizeof(media_format));
inTrack->EncodedFormat(&inFormat);
if (inFormat.IsAudio() && (audioCodec != NULL)) {
inAudTrack = inTrack;
memset(&outAudFormat, 0, sizeof(media_format));
outAudFormat.type = B_MEDIA_RAW_AUDIO;
raf = &(outAudFormat.u.raw_audio);
inTrack->DecodedFormat(&outAudFormat);
audioBuffer = new uint8[raf->buffer_size];
// audioFrameSize = (raf->format & media_raw_audio_format::B_AUDIO_SIZE_MASK)
// audioFrameSize = (raf->format & 0xf) * raf->channel_count;
outAudTrack = outFile->CreateTrack(&outAudFormat, audioCodec);
if (outAudTrack != NULL) {
if (outAudTrack->SetQuality(audioQuality / 100.0f) != B_OK
&& fWin->Lock()) {
fWin->SetAudioQualityLabel(
B_TRANSLATE("Audio quality not supported"));
fWin->Unlock();
}
}
} else if (inFormat.IsVideo() && (videoCodec != NULL)) {
inVidTrack = inTrack;
width = (int32)inFormat.Width();
height = (int32)inFormat.Height();
// construct desired decoded video format
memset(&outVidFormat, 0, sizeof(outVidFormat));
outVidFormat.type = B_MEDIA_RAW_VIDEO;
rvf = &(outVidFormat.u.raw_video);
rvf->last_active = (uint32)(height - 1);
rvf->orientation = B_VIDEO_TOP_LEFT_RIGHT;
rvf->display.format = B_RGB32;
rvf->display.bytes_per_row = 4 * width;
rvf->display.line_width = width;
rvf->display.line_count = height;
inVidTrack->DecodedFormat(&outVidFormat);
if (rvf->display.format == B_RGBA32) {
printf("fixing color space (B_RGBA32 -> B_RGB32)");
rvf->display.format = B_RGB32;
}
// Transfer the display aspect ratio.
if (inFormat.type == B_MEDIA_ENCODED_VIDEO) {
rvf->pixel_width_aspect
= inFormat.u.encoded_video.output.pixel_width_aspect;
rvf->pixel_height_aspect
= inFormat.u.encoded_video.output.pixel_height_aspect;
} else {
rvf->pixel_width_aspect
= inFormat.u.raw_video.pixel_width_aspect;
rvf->pixel_height_aspect
= inFormat.u.raw_video.pixel_height_aspect;
}
videoBuffer = new (std::nothrow) uint8[height
* rvf->display.bytes_per_row];
outVidTrack = outFile->CreateTrack(&outVidFormat, videoCodec);
if (outVidTrack != NULL) {
// DLM Added to use 3ivx Parameter View
const char* videoQualitySupport = NULL;
BView* encoderView = outVidTrack->GetParameterView();
if (encoderView) {
//.........这里部分代码省略.........