Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Mixing managed/unmanaged in C++/CLI

Mixing managed/unmanaged in C++/CLI

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpcsharpasp-netdesign
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jon Hulatt
    wrote on last edited by
    #1

    I have a legacy C app which uses FFmpeg APIs. I'm trying to update it, I want to write a UI in C# and keep the core in C. So, i'm dabbling in C++/CLI for the first time. It's my understanding that I can create a managed class wrapper, and have managed methods which take managed parameters, convert them as necessary to unmanaged equivalents (with System.Runtime.InteropServices.Marshal methods), do the work in native C, and then convert outputs from unmanaged to managed types for return. However, I'm stuck at the start. I've created a class like this:-

    ref class FFmpegCap
    {
    public:
    FFmpegCap(String^ inputVideo);

    protected:
    AVFormatContext *m_pFormatContext;

    };

    In my constructor, i need to call a C FFmpeg function to initialise the library, one of the parameters it requires is of type AVFormatContext ** . So, I call this function as follows:-

        if (av\_open\_input\_file(&m\_pFormatContext, pInputVideo ,NULL,0,NULL) != 0)
    {
    	
    }
    

    However, this fails to compile; error C2664: 'av_open_input_file' : cannot convert parameter 1 from 'cli::interior_ptr' to 'AVFormatContext **' It seems that the & operator is not doing what I expect of it! Any pointers? Thanks Jon

    using System.Beer;

    I 1 Reply Last reply
    0
    • J Jon Hulatt

      I have a legacy C app which uses FFmpeg APIs. I'm trying to update it, I want to write a UI in C# and keep the core in C. So, i'm dabbling in C++/CLI for the first time. It's my understanding that I can create a managed class wrapper, and have managed methods which take managed parameters, convert them as necessary to unmanaged equivalents (with System.Runtime.InteropServices.Marshal methods), do the work in native C, and then convert outputs from unmanaged to managed types for return. However, I'm stuck at the start. I've created a class like this:-

      ref class FFmpegCap
      {
      public:
      FFmpegCap(String^ inputVideo);

      protected:
      AVFormatContext *m_pFormatContext;

      };

      In my constructor, i need to call a C FFmpeg function to initialise the library, one of the parameters it requires is of type AVFormatContext ** . So, I call this function as follows:-

          if (av\_open\_input\_file(&m\_pFormatContext, pInputVideo ,NULL,0,NULL) != 0)
      {
      	
      }
      

      However, this fails to compile; error C2664: 'av_open_input_file' : cannot convert parameter 1 from 'cli::interior_ptr' to 'AVFormatContext **' It seems that the & operator is not doing what I expect of it! Any pointers? Thanks Jon

      using System.Beer;

      I Offline
      I Offline
      Iain Clarke Warrior Programmer
      wrote on last edited by
      #2

      There is a C++/CLI forum where you may get faster answers. Then again, one of the other people here may be typing an answer at the same time as me... Good luck, Iain

      Codeproject MVP for C++, I can't believe it's for my lounge posts...

      J 1 Reply Last reply
      0
      • I Iain Clarke Warrior Programmer

        There is a C++/CLI forum where you may get faster answers. Then again, one of the other people here may be typing an answer at the same time as me... Good luck, Iain

        Codeproject MVP for C++, I can't believe it's for my lounge posts...

        J Offline
        J Offline
        Jon Hulatt
        wrote on last edited by
        #3

        Thanks Iain, I should use my eyes more I think.

        using System.Beer;

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups