2 * Copyright (c) 1999-2000, Eric Moon.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions, and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions, and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * 3. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
26 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
27 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 // FileNodeInfoView.cpp
34 #include "FileNodeInfoView.h"
35 #include "MediaIcon.h"
36 #include "MediaString.h"
39 #include <MediaFile.h>
40 #include <MediaNode.h>
41 #include <MediaRoster.h>
42 #include <MediaTrack.h>
45 __USE_CORTEX_NAMESPACE
48 #define D_METHOD(x) //PRINT (x)
50 // -------------------------------------------------------- //
51 // *** ctor/dtor (public)
52 // -------------------------------------------------------- //
54 FileNodeInfoView::FileNodeInfoView(
56 : LiveNodeInfoView(ref
)
58 D_METHOD(("FileNodeInfoView::FileNodeInfoView()\n"));
60 // adjust view properties
61 setSideBarWidth(be_plain_font
->StringWidth(" File Format ") + 2 * InfoView::M_H_MARGIN
);
62 setSubTitle("Live File-Interface Node");
64 // if a ref is set for this file-interface display some info
65 // thru MediaFile and set the title appropriatly
70 error
= BMediaRoster::Roster()->GetRefFor(ref
->node(), &nodeFile
);
73 BMediaFile
file(&nodeFile
);
74 if (file
.InitCheck() == B_OK
)
76 // add separator field
79 // add "File Format" fields
80 media_file_format format
;
81 if (file
.GetFileFormatInfo(&format
) == B_OK
)
84 s
<< format
.pretty_name
<< " (" << format
.mime_type
<< ")";
85 addField("File Format", s
);
88 // add "Copyright" field
89 const char *copyRight
= file
.Copyright();
93 addField("Copyright", s
);
97 if (file
.CountTracks() > 0)
99 addField("Tracks", "");
100 for (int32 i
= 0; i
< file
.CountTracks(); i
++)
103 label
<< "(" << i
+ 1 << ")";
104 BMediaTrack
*track
= file
.TrackAt(i
);
108 if (track
->EncodedFormat(&format
) == B_OK
)
110 s
= MediaString::getStringFor(format
, false);
113 if ((format
.type
== B_MEDIA_ENCODED_AUDIO
)
114 || (format
.type
== B_MEDIA_ENCODED_VIDEO
))
117 media_codec_info codec
;
118 if (track
->GetCodecInfo(&codec
) == B_OK
)
120 s
<< "\n- Codec: " << codec
.pretty_name
;
123 s
<< " (ID: " << codec
.id
<< ")";
129 bigtime_t duration
= track
->Duration();
130 int hours
, minutes
, seconds
, frames
;
131 us_to_timecode(duration
, &hours
, &minutes
, &seconds
, &frames
);
133 sprintf(buffer
, "%02d:%02d:%02d:%02d", hours
, minutes
, seconds
, frames
);
134 s
<< "\n- Duration: " << buffer
;
138 if (track
->GetQuality(&quality
) == B_OK
)
140 s
<< "\n- Quality: " << quality
;
147 BEntry
entry(&nodeFile
);
148 char fileName
[B_FILE_NAME_LENGTH
];
149 entry
.GetName(fileName
);
156 title
+= " (no file)";
161 FileNodeInfoView::~FileNodeInfoView()
163 D_METHOD(("FileNodeInfoView::~FileNodeInfoView()\n"));
166 // END -- FileNodeInfoView.cpp --