DirectShow.NETCF

DirectShow.NETCF - Library that allows you to use DirectShow (play multimedia, capture/compress/recompress/preview audio and video) on Windows Mobile 5 or older devices.

Current version: 2.2.0.0

Available:
DirectShowNETCF

ComImports + PInvoke necessary API + some useful classes and methods

DirectShowNETCF.Player

Player class allows you to play audio and video files.
Methods:

  • public bool renderFile(string fileName) - build graph for required file if it possible
  • public bool play() - starts or continues play media file
  • public bool stop() - stops play file
  • public bool pause() - pauses play file
  • public bool setVideoWindow(IntPtr owner) - if it video file then you can set control that video should be rendered on

DirectShowNETCF.Camera

Allows you to preview video from camera, still images (still images and preview in the same time) in future record video.
Methods and Properties:

  • public CaptureType CapType - you can set one of type Preview, Still, PreviewStill
  • public bool init() - builds graph (note: you should set CaptureType, befor init camera)
  • public void release() - destroys graph (free all camera resources)
  • public void stop() - stops graph
  • public bool run(IntPtr owner) - runs graph and starts render captured video on required control
  • public bool run() - runs graph
  • public bool stillImage(string tmpPath) - stills and saves video.
  • public List<string> getMediaTypes() - returns list of supported resolutions
  • public void setMediaType(int index) - changes resolution from current to required
  • public bool resize(IntPtr owner, int width, int height) - call this method if you resized preview control and you want preview to be stretched for new control size
  • public bool flashOn() - turns flash on
  • public bool flashOff() - turns flash off
  • public bool zoomOut() - Zoom -
  • public bool zoomIn() - Zoom +
  • public bool focusMinus() - Focus -
  • public bool focusPlus() - Focus +
  • public bool autoFocusOff() - Turns Off autofocus
  • public bool autoFocusOn() - Turns On autofocus

DirectShowNETCF.Camera.AMCamera

Allows you to preview video from camera and grab raw frames, also allows to receive frames from camera without previewing
Methods and Properties:

  • public bool init(bool nullPreview) - builds graph
  • public void release() - destroys graph (free all camera resources)
  • public void stop() - stops graph
  • public bool run(IntPtr owner) - runs graph and starts render captured video on required control
  • public IntPtr grabFrame(ref long bufSize) - returns raw frame and buffer size, you have to free buffer when you dont need it (call DirectShowNETCF.PInvoke.LocalFree(IntPtr))
  • public bool getGrayScaleImage(IntPtr scan0, int stride) - grabs raw frame and make grayscale image from it. Now works wor rgb565 and YV12 formats.
  • public void getParams(out int width, out int height, out RawFrameFormat format) - returns width, height and format of raw frame
  • public void startDrawText(string text) - draws text on preview
  • stopDrawText() - stops draw text
  • public List<string> getMediaTypes() - returns list of supported resolutions
  • public void setMediaType(int index) - changes resolution from current to required (you have to call init and start again after changing resolution)
  • public bool resize(IntPtr owner, int width, int height) - call this method if you resized preview control and you want preview to be stretched for new control size
  • public bool flashOn() - turns flash on
  • public bool flashOff() - turns flash off
  • public bool zoomOut() - Zoom -
  • public bool zoomIn() - Zoom +
  • public bool focusMinus() - Focus -
  • public bool focusPlus() - Focus +
  • public bool autoFocusOff() - Turns Off autofocus
  • public bool autoFocusOn() - Turns On autofocus
  • public bool drawTarget(Rect rect, int type) - draws target on preview, you can define rect and target type
  • public bool stopDrawTarget() - stops draw target on preview
  • public bool getRgb565(IntPtr scan0) - grabs raw frame and makes rgb565 image from it. Now works wor rgb565 and YV12 formats.

DirectShowNETCF.Camera.AMCameraEx

Allows you to preview video from camera, grab raw RGB24 frames, apply effects for video, draws up to 10 bitmaps on preview
Methods and Properties:

  • public bool init(RotationType rotationType) - builds graph (you can choose type of rotation: None, Auto, Degree90)
  • public void release() - destroys graph (free all camera resources)
  • public void stop() - stops graph
  • public bool run(IntPtr owner) - runs graph and starts render captured video on required control
  • public void fixPreview(bool fix) - fixes preview for Toshiba and LG devices as they have incorrect Chroma buffer ordering
  • public IntPtr grabFrame() - returns raw frame (RGB24, size = 3 * width * height), you have to free buffer when you dont need it (call DirectShowNETCF.PInvoke.LocalFree(IntPtr))
  • public void applyEffect(Effets effect) - applies one of availabel effects (none, grayscale, black and white, sepia, edge detection and cropoval)
  • public void drawBitmap(IntPtr ptr, int id, int x, int y, int width, int height) - draws bitmap on preview
  • public void drawTransparentBitmap(IntPtr ptr, int id, int x, int y, int width, int height, int r, int g, int b) - draws bitmap on preview except pixels that the same with transparent color
  • public void blendBitmap(IntPtr ptr, int id, int x, int y, int width, int height, int blend) - blends preview and required bitmap
  • public void eraseBitmap(int id) - Erases earlier drawn bitmap
  • public void getRect(out int width, out int height) - returns width and height of raw frame
  • public List<string> getMediaTypes() - returns list of supported resolutions
  • public void setMediaType(int index) - changes resolution from current to required (you have to call init and start again after changing resolution)
  • public bool resize(IntPtr owner, int width, int height) - call this method if you resized preview control and you want preview to be stretched for new control size
  • public bool flashOn() - turns flash on
  • public bool flashOff() - turns flash off
  • public bool zoomOut() - Zoom -
  • public bool zoomIn() - Zoom +
  • public bool focusMinus() - Focus -
  • public bool focusPlus() - Focus +
  • public bool autoFocusOff() - Turns Off autofocus
  • public bool autoFocusOn() - Turns On autofocus

NullCamera

Allows to grab frames from camera without preview
Methods:

  • public bool init() - builds grap
  • public void release() - destroys graph
  • public void stop() - stops graph
  • public bool run() - runs graph

Events:

  • EventHandler<FrameEventArgs> GotFrame - fires every time we got new frame from camera.

AMCameraExControl 1.5.0.0

Control that allows you to preview stream from camera, grab bitmaps, draw bitmap on preview, control flash/focus/zoom (if your camera allows it)
Methods and Properties:

  • public bool Start() - starts preview
  • public void Stop() - stops camera
  • public Bitmap GrabFrame() - grabs current frame and returns it as Bitmap
  • public void FixPreview(bool needFix) - fix preview for Toshiba and LG devices
  • public void Overlay(Bitmap bmp, int id, int x, int y) - draws bitmap on preview, x and y - coord of left top corner, id - id that will be used to erase bitmap when you need
  • public void OverlayTransparent(Bitmap bmp, int id, int x, int y, Color transparentColor) - draws bitmap on preview except pixels that equal to transparentColor, x and y - coord of left top corner, id - id that will be used to erase bitmap when you need
  • public void BlendBitmap(Bitmap bmp, int id, int x, int y, byte blend) - blends preview and passed bitmap
  • public void eraseBitmap(int id) - Erases earlier drawn bitmap
  • public Effects Effect - allows you to aplly 1 of supported effects (None, GrayScale, BlackAndWhite, EdgeDetection, CropOval)
  • public bool FlashOn() - turns flash on
  • public bool FlashOff() - turns flash off
  • public bool ZoomOut() - Zoom -
  • public bool ZoomIn() - Zoom +
  • public bool FocusMinus() - Focus -
  • public bool FocusPlus() - Focus +
  • public bool AutoFocusOff() - Turns Off autofocus
  • public bool AutoFocusOn() - Turns On autofocus
  • Allows to handle mouse click (mouse down)

PlayerControl 1.5.0.0

Player class allows you to play audio and video files and mms streams. Also player allow to seek on media, control volume and grab frames.
Properties:

  • public bool Loop - if true then when video ended starts play again
  • public int VideoWidth - real video width
  • public int VideoHeight - real video height
  • public int Volume - you can control player volume (range 0-10000)
  • public int Balance - you can control sound balance
  • public int BitRate - video bitrate if possible to detect

Methods:

  • public void OpenFile(string filePath) - Builds graph that allows to play required file
  • public void Play() - starts or continues play media file
  • public void Stop() - stops play file
  • public void Pause() - pauses play file
  • public void Seek(TimeSpan position) - Sets media to required position
  • public TimeSpan GetDuration() - Gets Duration of media file

Events:

  • public event EventHandler MediaFailed - fiers if its impossible to render file
  • public event EventHandler MediaEnded -fiers when file plaed to the end
  • public event EventHandler<ProgressEventArgs> MediaProgress - fiers every 0,3 seconds and informs about current progress

Download Library and Examples

P.S:

If you need sources of library you can Buy it

233 Responses to “DirectShow.NETCF”

Pages: « 2411 10 9 8 7 6 5 4 3 2 [1] Show All

  1. 10
    admin Says:

    can you save raw data file and email it to me? also please email frame format (width, height, fixiel format)

  2. 9
    cHRIS Says:

    It kinda works…I can see the text being drawn in extemely small font.

    So should I that the sample grabber works? And if it works why can’t I save the data in a file? I can seen that grabFrame() returns size > 0.

    I think that the pointer is actually filled with the image data, I’m just unable to use them…maybe the device is lying about the pixel format??

    Anyway, I’ll try passing the raw data to another application and try and process them that way….maybe that will work.

  3. 8
    admin Says:

    the easiest way to check if sample grabber works is to try draw text, but as i remeber it should not work correct on RGB formats

  4. 7
    cHRIS Says:

    i would post source, but I haven’t changed anything in your example, I just compiled and run. Anyway, i will investigate further.

  5. 6
    admin Says:

    hm… maybe sample grabber not work correct, but if preview works then samplegrabber sgould work correct too! maybe you doing something wrong, but i definitly dont know what

  6. 5
    cHRIS Says:

    Thx for your quick response.

    I assume you are refering to grabFrame() not getFrame()

    Still no luck, I get all black pixels. Any more ideas?

  7. 4
    admin Says:

    AMCamera got public method getFrame (it return IntPtr that contain raw buffer)

    [csharp]
    int width;
    int height;
    DirectShowNETCF.RawFrameFormat format;

    cam_.getParams(out width, out height, out format);

    Bitmap bmp = new Bitmap(width, height);
    System.Drawing.Imaging.BitmapData data = bmp.LockBits(new Rectangle(0, 0, width, height),
    System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format16bppRgb565);

    //cam_.getGrayScaleImage(data.Scan0, data.Stride);

    long size = 0;
    IntPtr buff = cam_.getFrame(ref size);
    Marshal.WriteIntPtr(data.Scan0, buff);
    DirectShowNETCF.PInvoke.LocalFree(buff);

    bmp.UnlockBits(data);
    bmp.Save(textBox1.Text, System.Drawing.Imaging.ImageFormat.Bmp);
    [/csharp]

  8. 3
    cHRIS Says:

    You are right!! I tried it on my old HTC (3600) which returns the data in YV12. The function returns true, however I still get a black image. However, this phone is behaving very strangely lately, so I can’t b sure what’s wrong.

    On my new HTC, which returns data in 16bppRgb565 how can I make that work. I assume something needs to be changed in the native dll, right? Is your source available, I’d be happy to do it.

    I would b eternally greatfull if you could provide a solution, otherwise I will have to implement the whole thing from scratch :(

    Thx in advance!

  9. 2
    admin Says:

    GetGrayScale works only on YUV formats, on Rgb565 it should return false!

    P.S. it aint problem to implement for RGB formats

  10. 1
    cHRIS Says:

    I have downloaded DirectShowNETCF and seems to be working fine! Great job, took me a week to implement half of the functionality in C++ :) - too bad I hadn’t come across this lib earlier, would have saved loads of time!

    Still, I’,m having a problem. The “GetGrayScale” button in the AMCamera example doesn’t seem to work. The bmp generated contains black pixels only.
    I tried changing the PixelFormat to Format16bppRgb565 (are reported from cam_.getParams) but still no luck.

    Any ideas would be greatly appreciated!

Pages: « 2411 10 9 8 7 6 5 4 3 2 [1] Show All

Leave a Reply