已阅读5页,还剩7页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
主题 主题 JavaJava MediaMedia FrameworkFramework 本地玩转摄像头本地玩转摄像头 正文 发表时间 2010 08 04 最后修改 2010 08 10 猎头职位 上海上海 上海 天会皓闻诚聘资深 Java 架构师 相关文章 JMF 能否扩展支持除 WAV 外的格式 求求你们 千万别再说自己是 REST 了 Failed to realize com sun media PlaybackEngine 480457 推荐圈子 sip communicator 更多相关推荐 1 1 简介 简介 The JavaTM Media Framework JMF is an application programming interface API for incorporating media data such as audio and video into Java applications and applets It is specifically designed to take advantage of Java platform features 这个框架是 SUN 公司出的 最新更新至 2003 年 用 JMF 来处理图像和音频设备 并直接应用到 JAVA 应用程序中 虽然年代有点久远 但却还是可以用的 The JMF 2 1 1 Reference Implementation supports SunVideo SunVideoPlus capture devices on Solaris On Windows most capture devices that have VFW drivers are supported On Linux devices that have a Video4Linux driver are expected to work but not extensively tested 今天小试了下 自己的 laptop 也有个摄像头 录制了一段视频到本地 第一次 玩这个东西 2 2 模型 模型 JMF 的模型如下 主题 主题 JavaJava MediaMedia FrameworkFramework 本地玩转摄像头本地玩转摄像头 正文 基本上是摄像头数据 文件数据 网络媒体流通过 process 输出到设备 文件 或网络中 Design Goals for JMF 1 Be easy to program 2 Support capturing media data 3 Enable the development of media streaming and conferencing applications in Java 4 Enable advanced developers and technology providers to implement custom solutions based on the existing API and easily integrate new features with the existing framework 5 Provide access to raw media data 6 Enable the development of custom downloadable demultiplexers codecs effects processors multiplexers and renderers JMF plug ins Design Goals for RTP RTP 是 JMF 数据流在网络上的传输协议 1 Enable the development of media streaming and conferencing applications in Java 主题 主题 JavaJava MediaMedia FrameworkFramework 本地玩转摄像头本地玩转摄像头 正文 2 Support media data reception and transmission using RTP and RTCP 3 Support custom packetizer and depacketizer plug ins through the JMF 2 0 plug in architecture 4 Be easy to program 3 3 媒体数据展现 媒体数据展现 Streaming Media 媒体流 可以存储为多种文件格式或通过 HTTP RTP 等协议传输在网络上 Media Presentation Most time based media is audio or video data that can be presented through output devices such as speakers and monitors Such devices are the most common destination for media data output Media streams can also be sent to other destinations for example saved to a file or transmitted across the network An output destination for media data is sometimes referred to as a data sink Media Data Storage and Transmission A DataSink is used to read media data from a DataSource and render the media to some destination generally a destination other than a presentation device A particular DataSink might write data to a file write data across the network or function as an RTP broadcaster 主题 主题 JavaJava MediaMedia FrameworkFramework 本地玩转摄像头本地玩转摄像头 正文 DataSink 用来做数据存储和传输 开始 presenting time based media Presenting Time Based Media To present time based media such as audio or video with JMF you use a Player Playback can be controlled programmatically or you can display a control panel component that enables the user to control playback interactively If you have several media streams that you want to play you need to use a separate Player for each one to play them in sync you can use one of the Player objects to control the operation of the others 基本上是说播放实时多媒体需要用到 Player 且每个单独的媒体需要单独的 Player 代码如下 Java 代码 1 create processor 2 ProcessorModel processorModel new ProcessorModel mixe dDataSource outputFormat outputType 3 创建 model 类似 JTable 控件的 JModel The ProcessorModel defines the input and output requir ements for the Processor 4 Processor processor null 5 try 6 7 processor Manager createRealizedProcessor process orModel 创建 model 类似 JTable 控件的 JModel 8 9 catch IOException e Stdout logAndAbortException e 主题 主题 JavaJava MediaMedia FrameworkFramework 本地玩转摄像头本地玩转摄像头 正文 10 catch NoProcessorException e Stdout logAndAbortExce ption e 11 catch CannotRealizeException e Stdout logAndAbortEx ception e 创建 processor 后 可以装进不同的 compont 里来 present For example you can call getControls to determine if a Player supports the CachingControl interface Java 代码 1 Control controls player getControls 2 3 for int i 0 i controls length i 4 5 if controls i instanceof CachingControl 6 cachingControl CachingControl controls i 7 8 JMF 提供了很多 播放器 当然也提供了基本的控制 比如播放 停止以及 播放信息等等 控制产生事件 Responding to Media Events ControllerListener is an asynchronous interface for handling events generated by Controller objects for example Java 代码 主题 主题 JavaJava MediaMedia FrameworkFramework 本地玩转摄像头本地玩转摄像头 正文 1 if event instanceof EventType 2 3 else if event instanceof OtherEventType 4 5 6 if event instanceof EventType else if event instanceo f OtherEventType JMF 提供 ControllerAdapter Java 代码 1 player addControllerListener new ControllerAdapter 2 public void endOfMedia EndOfMediaEvent e 3 Controller controller e getSource 4 controller stop 5 controller setMediaTime new Time 0 6 controller deallocate 7 8 ControllerAdapter automatically dispatches the event to the appropriate event method filtering out the events that you re not interested in 自动为您分发事件并过滤不需要的事件 There is a movie in Applet 展现到 applet Java 代码 1 import java applet 2 import java awt 3 import 4 import javax media 5 6 public class PlayerApplet extends Applet implements ControllerL istener 7 Player player null 8 public void init 主题 主题 JavaJava MediaMedia FrameworkFramework 本地玩转摄像头本地玩转摄像头 正文 9 setLayout new BorderLayout 10 String mediaFile getParameter FILE 11 try 12 URL mediaURL new URL getDocumentBase mediaFile 13 player Manager createPlayer mediaURL 14 player addControllerListener this 15 16 catch Exception e 17 System err println Got exception e 18 19 20 public void start 21 player start 22 23 public void stop 24 player stop 25 player deallocate 26 27 public void destroy 28 player close 29 30 public synchronized void controllerUpdate ControllerEvent ev ent 31 if event instanceof RealizeCompleteEvent 32 Component comp 33 if comp player getVisualComponent null 34 add Center comp 35 if comp player getControlPanelComponent null 36 add South comp 37 validate 38 39 40 主题 主题 JavaJava MediaMedia FrameworkFramework 本地玩转摄像头本地玩转摄像头 正文 Presenting RTP Media Streams Creating a Player for RTP session Java 代码 1 String url rtp 224 144 251 104 49150 audio 1 2 3 MediaLocator mrl new MediaLocator url 4 5 if mrl null 6 System err println Can t build MRL for RTP 7 return false 8 9 10 Create a player for this rtp session 11 try 12 player Manager createPlayer mrl 13 catch NoPlayerException e 14 System err println Error e 15 return false 16 catch MalformedURLException e 17 System err println Error e 18 return false 19 catch IOException e 20 System err println Error e 21 return false 22 4 4 媒体数据处理 媒体数据处理 Converting Media Data from One Format to Another 你可以调整媒体的格式 Specifying the Media Destination 主题 主题 JavaJava MediaMedia FrameworkFramework 本地玩转摄像头本地玩转摄像头 正文 你可以指定录像保存的方式 比如输出到文件 输出到另一个 player Saving captured media data to a file Java 代码 1 DataSink sink 2 MediaLocator dest new MediaLocator file newfile wav 3 try 4 sink Manager createDataSink p getDataOutput dest 5 sink open 6 sink start 7 catch Exception 5 5 扩展 扩展 JMFJMF Custom JMF plug ins can be used seamlessly with Processors that support the plug in API After you implement your plug in you need to install it and register it with the PlugInManager to make it available to plug in compatible Processors Implementing a Codec or Effect Plug In Codec plug ins are used to decode compressed media data convert media data from one format to another or encode raw media data into a compressed format 用户可以自行扩展压缩格式 以及格式转换 Implementing a Renderer Plug In 主题 主题 JavaJava MediaMedia FrameworkFramework 本地玩转摄像头本地玩转摄像头 正文 It is a single input processing component with no output Renderer plug ins read data from a DataSource and typically present the media data to the user but can also be used to provide access to the processed media data for use by another application or device To make a custom plug in available to a Processor through the TrackControl interface you need to register it with the PlugInManager Java 代码 1 Name of the new plugin 2 string GainPlugin new String COM mybiz media GainEffect 3 4 Supported input Formats 5 Format supportedInputFormats new Format 6 new AudioFormat 7 AudioFormat LINEAR 8 Format NOT SPECIFIED 9 16 10 Format NOT SPECIFIED 11 AudioFormat LITTLE ENDIAN 12 AudioFormat SIGNED 13 16 14 Format NOT SPECIFIED 15 Format byteArray 16 17 18 19 20 Supported output Formats 21 Format supportedOutputFormats new Format 22 new AudioFormat 23 AudioFormat LINEAR 24 Format NOT SPECIFIED 25 16 26 Format NOT SPECIFIED 主题 主题 JavaJava MediaMedia FrameworkFramework 本地玩转
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年挖掘机操作证考试题(附答案)
- 保险公司面试准备面试流程及应对策略
- 2025公务员考试行测真题集
- 全省公务员面试主题培训各个领域重点内容
- 企业社保管理与员工福利优化
- 2025至2030中国高压球囊导管行业项目调研及市场前景预测评估报告
- 2025至2030中国休闲旅游帐篷行业市场深度调研及发展趋势与投资报告
- 2025-2030中国氢能城市燃气掺混试点效果与推广策略
- 2025至2030中国无线气体检测技术行业项目调研及市场前景预测评估报告
- 2025至2030细胞分析仪器行业项目调研及市场前景预测评估报告
- 2025年前三季度中国股权投资市场研究报告
- 2026南方传媒校园招聘笔试考试参考试题及答案解析
- 中国人保招聘面试题及答案
- 2022年申报第二类医疗器械产品注册完整资料参考
- 乙肝梅毒艾滋知识培训
- 科技创新归纳
- 柳公权书法介绍
- 2025年郑州铁路职业技术学院单招职业技能考试题库及答案
- 海南医院面试题目及答案
- 血液内科缺铁性贫血教案
- GB/T 5760-2025塑料离子交换树脂氢氧型阴离子交换树脂交换容量的测定
评论
0/150
提交评论